From 71d3645885806c5a89eae47afe344a673df417cd Mon Sep 17 00:00:00 2001 From: Jess Telford Date: Wed, 4 Apr 2018 11:04:54 +1000 Subject: [PATCH] graphcool init only write package.json if none exists Fixes #354 --- .../graphcool-cli-core/src/commands/init/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/packages/graphcool-cli-core/src/commands/init/index.ts b/cli/packages/graphcool-cli-core/src/commands/init/index.ts index fc4a22bee..946ecc9f9 100644 --- a/cli/packages/graphcool-cli-core/src/commands/init/index.ts +++ b/cli/packages/graphcool-cli-core/src/commands/init/index.ts @@ -115,10 +115,12 @@ To force the init process in this folder, use ${chalk.green( this.out.action.stop() this.out.log(`${chalk.dim.bold('\nWritten files' + ':')}`) - fs.writeFileSync( - path.join(this.config.definitionDir, 'package.json'), - JSON.stringify(pjson, null, 2), - ) + if (!fs.accessSync(path.join(this.config.definitionDir, 'package.json')) { + fs.writeFileSync( + path.join(this.config.definitionDir, 'package.json'), + JSON.stringify(pjson, null, 2), + ) + } const createdFiles = flatten( this.definition.definition!.modules.map(module => Object.keys(module.files),