UNPKG

482 BJavaScriptView Raw
1import fs from 'fs';
2import path from 'path';
3
4/* istanbul ignore next */
5export default function createConfigFileInHomedir(options) {
6 // Create config file in the homedir, if it does not exist.
7 // Saving to a globally installed package might cause problems.
8 try {
9 fs.writeFileSync(
10 path.join(options.configHomedirPath, options.configFilename),
11 '{}',
12 {
13 encoding: 'utf8',
14 flag: 'wx',
15 }
16 );
17 } catch (_error) {
18 // Do nothing, file might already exist
19 }
20}