Skip to content
Permalink
Browse files

fix(initializer): electron versions for babel-preset-env should be st…

…rings

Removes the following warning when running `electron-forge start`:

> Warning, the following targets are using a decimal version:
>
>   electron: 1.7
>
> We recommend using a string for minor/patch versions to avoid numbers like 6.10
> getting parsed as 6.1, which can lead to unexpected behavior.
  • Loading branch information
malept committed Dec 5, 2017
1 parent 0e18fe3 commit 35120b1c38cef1c5bf7e93643a214c28ec5a719f
Showing with 7 additions and 5 deletions.
  1. +1 −1 src/init/init-npm.js
  2. +4 −2 test/slow/api_spec_slow.js
  3. +2 −2 tmpl/_compilerc
@@ -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');
@@ -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', () => {
@@ -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"],

0 comments on commit 35120b1

Please sign in to comment.
You can’t perform that action at this time.