From 75366bfe9b211800cd2c154bb2cd37ce7d31b5a3 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sun, 4 Dec 2016 20:20:31 +1100 Subject: [PATCH] feat(importer): fix the projects gitignore on import --- src/electron-forge-import.js | 9 +++++++++ src/util/terminate.js | 29 +---------------------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/electron-forge-import.js b/src/electron-forge-import.js index e1cfac603..10bf5dcc5 100644 --- a/src/electron-forge-import.js +++ b/src/electron-forge-import.js @@ -138,6 +138,15 @@ const main = async () => { packageJSON.config.forge = JSON.parse(await fs.readFile(path.resolve(__dirname, '../tmpl/package.json'))).config.forge; await writeChanges(); + + const gitignoreSpinner = ora.ora('Fixing .gitignore').start(); + if (await fs.exists(path.resolve(dir, '.gitignore'))) { + const gitignore = await fs.readFile(path.resolve(dir, '.gitignore')); + if (!gitignore.includes('out')) { + await fs.writeFile(path.resolve(dir, '.gitignore'), `${gitignore}\nout/`); + } + } + gitignoreSpinner.succeed(); }; main(); diff --git a/src/util/terminate.js b/src/util/terminate.js index 40903775b..bd3f4f8bf 100644 --- a/src/util/terminate.js +++ b/src/util/terminate.js @@ -4,17 +4,13 @@ import ora from 'ora'; const d = debug('electron-forge:lifecycle'); -const runningOras = {}; - process.on('unhandledRejection', (err) => { - Object.keys(runningOras).forEach(key => runningOras[key].fail()); process.stdout.write('\n\nAn unhandled rejection has occurred inside Forge:\n'); console.error(colors.red(err.stack || JSON.stringify(err))); process.exit(1); }); process.on('uncaughtException', (err) => { - Object.keys(runningOras).forEach(key => runningOras[key].fail()); process.stdout.write('\n\nAn unhandled exception has occurred inside Forge:\n'); console.error(colors.red(err.stack || JSON.stringify(err))); process.exit(1); @@ -44,28 +40,5 @@ if (process.env.DEBUG && process.env.DEBUG.includes('electron-forge')) { return fake; }; } else { - let oraID = 1; - ora.ora = (name) => { - const createdOra = ora(name); - createdOra.id = oraID; - const fns = {}; - fns.start = createdOra.start.bind(createdOra); - fns.stop = createdOra.stop.bind(createdOra); - fns.succeed = createdOra.succeed.bind(createdOra); - fns.fail = createdOra.fail.bind(createdOra); - createdOra.start = () => { - runningOras[createdOra.id] = createdOra; - fns.start(); - return createdOra; - }; - ['stop', 'succeed', 'fail'].forEach((fnName) => { - createdOra[fnName] = (...args) => { - delete runningOras[createdOra.id]; - fns[fnName](...args); - return createdOra; - }; - }); - oraID += 1; - return createdOra; - }; + ora.ora = ora; }