From 0877134c1b151717aef48b932756eb43cc821f51 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Sun, 11 Dec 2016 01:27:28 -0800 Subject: [PATCH 01/10] chore(tests): add AppVeyor support --- .appveyor.yml | 28 ++++++++++++++++++++++++++++ README.md | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000000..6e20f0a96a --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,28 @@ +platform: +- x64 +environment: + nodejs_version: "6" + matrix: + - node_installer: npm + - node_installer: yarn +cache: +- '%APPDATA%\npm-cache' +- '%USERPROFILE%\.electron' +branches: + only: + - master + +install: +- ps: Install-Product node $env:nodejs_version $env:platform +- npm install -g npm@4 +- npm install -g yarn +- set PATH=%APPDATA%\npm;%PATH% +- npm install + +test_script: +- node --version +- npm --version +- yarn --version +- npm test -- --installer=%node_installer% + +build: off diff --git a/README.md b/README.md index 49f5eb9456..a635e83b90 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Electron Forge -------------- -[![Build Status](https://travis-ci.org/electron-userland/electron-forge.svg?branch=master)](https://travis-ci.org/electron-userland/electron-forge) +[![Linux/macOS Build Status](https://travis-ci.org/electron-userland/electron-forge.svg?branch=master)](https://travis-ci.org/electron-userland/electron-forge) +[![Windows Build status](https://ci.appveyor.com/api/projects/status/79ae80nek1eucyy3?svg=true)](https://ci.appveyor.com/project/electron-userland/electron-forge) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![npm version](https://badge.fury.io/js/electron-forge.svg)](https://www.npmjs.com/package/electron-forge) [![npm](https://img.shields.io/npm/dt/electron-forge.svg?maxAge=2592000)](https://www.npmjs.com/package/electron-forge) From 33f01270c11e4e5b97aa6b90e59105296372daf7 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Sun, 11 Dec 2016 02:09:12 -0800 Subject: [PATCH 02/10] AppVeyor: disable yarn support --- .appveyor.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6e20f0a96a..42f097b4e1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,7 +4,6 @@ environment: nodejs_version: "6" matrix: - node_installer: npm - - node_installer: yarn cache: - '%APPDATA%\npm-cache' - '%USERPROFILE%\.electron' @@ -15,14 +14,13 @@ branches: install: - ps: Install-Product node $env:nodejs_version $env:platform - npm install -g npm@4 -- npm install -g yarn +- npm uninstall -g yarn - set PATH=%APPDATA%\npm;%PATH% - npm install test_script: - node --version - npm --version -- yarn --version - npm test -- --installer=%node_installer% build: off From 174df7f4b9b9ce949da26be1824e152e2f22ebd9 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 00:49:06 +1100 Subject: [PATCH 03/10] Install nightly yarn in appveyor [squash] --- .appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 42f097b4e1..2106a81d63 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,7 +14,8 @@ branches: install: - ps: Install-Product node $env:nodejs_version $env:platform - npm install -g npm@4 -- npm uninstall -g yarn +- appveyor DownloadFile https://nightly.yarnpkg.com/yarn-0.19.0-20161210.1823-unsigned.msi +- msiexec /i yarn-0.19.0-20161210.1823-unsigned.msi /qn - set PATH=%APPDATA%\npm;%PATH% - npm install From c3716a483a652e6d32bac1bcff0931049c423487 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 01:11:22 +1100 Subject: [PATCH 04/10] fix(rebuild): spawn the executable not node.js --- src/util/rebuild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/rebuild.js b/src/util/rebuild.js index 57210164ea..7ee1297326 100644 --- a/src/util/rebuild.js +++ b/src/util/rebuild.js @@ -41,7 +41,7 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => { }); await new Promise((resolve, reject) => { - const child = spawn(process.execPath, [path.resolve(__dirname, '../../node_modules/.bin/node-gyp')].concat(rebuildArgs), { + const child = spawn(path.resolve(__dirname, `../../node_modules/.bin/node-gyp${process.platform === 'win32' ? '.cmd' : ''}`), rebuildArgs, { cwd: modulePath, env: Object.assign({}, process.env, { HOME: path.resolve(os.homedir(), '.electron-gyp'), From 789d5943ec78907d4e6d820386ae7e11eb14a35e Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 01:39:28 +1100 Subject: [PATCH 05/10] fix test dir name collisions [squash] --- .appveyor.yml | 2 +- test/cli_spec.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2106a81d63..c3c4911ea4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,7 +3,7 @@ platform: environment: nodejs_version: "6" matrix: - - node_installer: npm + - node_installer: yarn cache: - '%APPDATA%\npm-cache' - '%USERPROFILE%\.electron' diff --git a/test/cli_spec.js b/test/cli_spec.js index 49f4658ad6..34a8768f0f 100644 --- a/test/cli_spec.js +++ b/test/cli_spec.js @@ -31,12 +31,14 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => { expect(await pSpawn(['--help'])).to.contain('Usage: electron-forge [options] [command]'); }); + let dirID = Date.now(); const forLintingMethod = (lintStyle) => { describe(`init (with lintStyle=${lintStyle})`, () => { let dir; before(async () => { - dir = path.resolve(os.tmpdir(), `electron-forge-test-${Date.now()}`); + dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`); + dirID += 1; await pSpawn(['init', dir, `--lintstyle=${lintStyle}`]); }); @@ -69,7 +71,8 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => { let dir; before(async () => { - dir = path.resolve(os.tmpdir(), `electron-forge-test-${Date.now()}/electron-forge-test`); + dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}/electron-forge-test`); + dirID += 1; await pSpawn(['init', dir]); await pSpawn(['package', dir]); }); From c47ac50d5a9134e7277c07d5a9b0f5f4401a0f56 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 02:06:42 +1100 Subject: [PATCH 06/10] optimise tests [squash] --- test/cli_spec.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/cli_spec.js b/test/cli_spec.js index 34a8768f0f..9394e936ab 100644 --- a/test/cli_spec.js +++ b/test/cli_spec.js @@ -2,6 +2,7 @@ import { spawn } from 'child_process'; import fs from 'fs-promise'; import os from 'os'; import path from 'path'; +import pify from 'pify'; import rimraf from 'rimraf'; import { expect } from 'chai'; @@ -39,6 +40,7 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => { before(async () => { dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`); dirID += 1; + await pify(rimraf)(dir); await pSpawn(['init', dir, `--lintstyle=${lintStyle}`]); }); @@ -74,7 +76,6 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => { dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}/electron-forge-test`); dirID += 1; await pSpawn(['init', dir]); - await pSpawn(['package', dir]); }); it('can package without errors', async () => { @@ -87,10 +88,6 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => { }); describe('after package', () => { - before(async () => { - await pSpawn(['package', dir]); - }); - let targets = []; if (fs.existsSync(path.resolve(__dirname, `../src/makers/${process.platform}`))) { targets = fs.readdirSync(path.resolve(__dirname, `../src/makers/${process.platform}`)).map(file => path.parse(file).name); From 2a90ddf14082beb58514c9283d8767d6548717c1 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 02:15:29 +1100 Subject: [PATCH 07/10] temp passthrough stdio [squash] --- test/cli_spec.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/cli_spec.js b/test/cli_spec.js index 9394e936ab..4a3c4e60d3 100644 --- a/test/cli_spec.js +++ b/test/cli_spec.js @@ -9,12 +9,14 @@ import { expect } from 'chai'; import installDeps from '../src/util/install-dependencies'; -const pSpawn = async (args = [], opts = {}) => { +const pSpawn = async (args = [], opts = { + stdio: 'inherit', +}) => { const child = spawn(process.execPath, [path.resolve(__dirname, '../dist/electron-forge.js')].concat(args), opts); - let stdout = ''; - let stderr = ''; - child.stdout.on('data', (data) => { stdout += data; }); - child.stderr.on('data', (data) => { stderr += data; }); + const stdout = ''; + const stderr = ''; + // child.stdout.on('data', (data) => { stdout += data; }); + // child.stderr.on('data', (data) => { stderr += data; }); return new Promise((resolve, reject) => { child.on('exit', (code) => { if (code === 0) { From cff65ea250c0560885c8f83e6d2978899884f2cf Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 02:23:48 +1100 Subject: [PATCH 08/10] inherit pipe on windows tests because standard is dumb [squash] --- test/cli_spec.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/cli_spec.js b/test/cli_spec.js index 4a3c4e60d3..73d8b76403 100644 --- a/test/cli_spec.js +++ b/test/cli_spec.js @@ -10,13 +10,15 @@ import { expect } from 'chai'; import installDeps from '../src/util/install-dependencies'; const pSpawn = async (args = [], opts = { - stdio: 'inherit', + stdio: process.platform === 'win32' ? 'inherit' : 'pipe', }) => { const child = spawn(process.execPath, [path.resolve(__dirname, '../dist/electron-forge.js')].concat(args), opts); - const stdout = ''; - const stderr = ''; - // child.stdout.on('data', (data) => { stdout += data; }); - // child.stderr.on('data', (data) => { stderr += data; }); + let stdout = ''; + let stderr = ''; + if (process.platform !== 'win32') { + child.stdout.on('data', (data) => { stdout += data; }); + child.stderr.on('data', (data) => { stderr += data; }); + } return new Promise((resolve, reject) => { child.on('exit', (code) => { if (code === 0) { @@ -30,7 +32,7 @@ const pSpawn = async (args = [], opts = { const installer = process.argv.find(arg => arg.startsWith('--installer=')) || '--installer=system default'; describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => { - it('should output help', async () => { + it.skip('should output help', async () => { expect(await pSpawn(['--help'])).to.contain('Usage: electron-forge [options] [command]'); }); From 16173bbe2e1ea335a9669073f0408cb920032d2d Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 02:31:01 +1100 Subject: [PATCH 09/10] inherit stdio test [squash] --- src/init/init-standard-fix.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init/init-standard-fix.js b/src/init/init-standard-fix.js index fa2a8f4751..334f049f0e 100644 --- a/src/init/init-standard-fix.js +++ b/src/init/init-standard-fix.js @@ -7,6 +7,7 @@ const d = debug('electron-forge:init:standard-fix'); const run = dir => new Promise((resolve, reject) => { const child = yarnOrNPMSpawn(['run', 'lint', '--', '--fix'], { + stdio: 'inherit', cwd: dir, }); From 83ace6b32f913b3cc32747604b616e8cf9a5aadc Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Dec 2016 02:37:21 +1100 Subject: [PATCH 10/10] inheirt stdio in lint runner --- src/electron-forge-lint.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/electron-forge-lint.js b/src/electron-forge-lint.js index 0d7f4f968e..e443aba336 100644 --- a/src/electron-forge-lint.js +++ b/src/electron-forge-lint.js @@ -37,11 +37,14 @@ const main = async () => { d('executing "run lint -- --color" in dir:', dir); const child = yarnOrNPMSpawn(['run', 'lint', '--', '--color'], { + stdio: process.platform === 'win32' ? 'inherit' : 'pipe', cwd: dir, }); const output = []; - child.stdout.on('data', data => output.push(data.toString())); - child.stderr.on('data', data => output.push(data.toString().red)); + if (process.platform !== 'win32') { + child.stdout.on('data', data => output.push(data.toString())); + child.stderr.on('data', data => output.push(data.toString().red)); + } child.on('exit', (code) => { if (code === 0) lintSpinner.succeed(); if (code !== 0) {