diff --git a/src/init/init-npm.js b/src/init/init-npm.js index 447637ecbc..046b08e35f 100644 --- a/src/init/init-npm.js +++ b/src/init/init-npm.js @@ -75,7 +75,7 @@ export default async (dir, lintStyle) => { const envTarget = content.env[profile]['application/javascript'].presets.find(x => x[0] === 'env'); // parseFloat strips the patch version // parseFloat('1.3.2') === 1.3 - envTarget[1].targets.electron = parseFloat(electronPrebuilt.version); + envTarget[1].targets.electron = parseFloat(electronPrebuilt.version).toString(); } await fs.writeFile(path.join(dir, '.compilerc'), JSON.stringify(content, null, 2), 'utf8'); diff --git a/test/slow/api_spec_slow.js b/test/slow/api_spec_slow.js index 9b8ac16194..a74aff19b2 100644 --- a/test/slow/api_spec_slow.js +++ b/test/slow/api_spec_slow.js @@ -62,10 +62,12 @@ describe(`electron-forge API (with installer=${nodeInstaller})`, () => { expect(await fs.pathExists(path.resolve(dir, 'node_modules/electron-forge')), 'electron-forge should exist').to.equal(true); }); - it('should have set the .compilerc electron version to be a float', async () => { + it('should have set the .compilerc electron version to be a string', async () => { expectProjectPathExists('.compilerc', 'file'); const compilerc = JSON.parse(await fs.readFile(path.resolve(dir, '.compilerc'))); - expect(compilerc.env.development['application/javascript'].presets[0][1].targets.electron).to.be.a('number'); + const electronVersion = compilerc.env.development['application/javascript'].presets[0][1].targets.electron; + expect(electronVersion).to.be.a('string'); + expect(electronVersion.split('.').length).to.equal(2); }); describe('lint', () => { diff --git a/tmpl/_compilerc b/tmpl/_compilerc index f1927a1c68..6c1a6c295c 100644 --- a/tmpl/_compilerc +++ b/tmpl/_compilerc @@ -3,7 +3,7 @@ "development": { "application/javascript": { "presets": [ - ["env", { "targets": { "electron": 1.4 } }], + ["env", { "targets": { "electron": "1.4" } }], "react" ], "plugins": ["transform-async-to-generator"], @@ -13,7 +13,7 @@ "production": { "application/javascript": { "presets": [ - ["env", { "targets": { "electron": 1.4 } }], + ["env", { "targets": { "electron": "1.4" } }], "react" ], "plugins": ["transform-async-to-generator"],