diff --git a/lib/commands/config.js b/lib/commands/config.js index 5932d29b5..866234b94 100644 --- a/lib/commands/config.js +++ b/lib/commands/config.js @@ -6,6 +6,7 @@ const inquirer = require('inquirer'); const path = require('path'); const yaml = require('js-yaml'); const util = require('util'); +const mkdirp = require('mkdirp'); const getProfile = require('../profile').getProfileFromFile; @@ -46,7 +47,11 @@ async function config() { ]; const newProf = await inquirer.prompt(questions); - const profPath = path.join(os.homedir(), '.fcli/config.yaml'); + const configDir = path.join(os.homedir(), '.fcli'); + + await mkdirp(configDir); + + const profPath = path.join(configDir, 'config.yaml'); const isExists = await exists(profPath); var profYml; @@ -72,9 +77,6 @@ async function config() { }; } - - - await writeFile(profPath, yaml.dump(profYml)); }