Skip to content

Commit

Permalink
fix: add native addons build for tests env
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Roman committed Oct 9, 2018
1 parent 1102fb9 commit 2798c0e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ branches:

before_script:
- yarn keys:decipher
- yarn build:modules
- yarn build:modules-no-electron
- yarn test

script:
- if [[ "$TRAVIS_BRANCH" == "stable" ]]; then yarn build:modules; fi
- if [[ "$TRAVIS_BRANCH" == "stable" ]]; then yarn dist:ci; else yarn build:prod; fi

cache:
Expand Down
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ install:

before_build:
- yarn keys:decipher
- yarn build:modules
- yarn build:modules-no-electron
- yarn test

build_script:
- if %APPVEYOR_REPO_BRANCH%==stable (yarn build:modules)
- if %APPVEYOR_REPO_BRANCH%==stable (yarn dist:ci) else (yarn build:prod)

test: off
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"build:client": "parallel-webpack --progress --config=webpack/client.config.js",
"build:client-no-loader": "cross-env NO_LOADER=true parallel-webpack --progress --config=webpack/client.config.js",
"build:modules": "node scripts/build_modules.js",
"build:modules-no-electron": "cross-env NO_ELECTRON=true node scripts/build_modules.js",
"run:app": "yarn lint:app && yarn build:app && electron .",
"run:server": "yarn lint:server && yarn build:server && yarn start",
"run:client": "yarn lint:client && yarn build:client && yarn start",
Expand Down
14 changes: 9 additions & 5 deletions scripts/build_modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ const { readdir, statSync } = require('fs-extra');
const { resolve } = require('path');
const { cd, exec, grep, mkdir, mv, rm } = require('shelljs');

const electronUrl = 'https://atom.io/download/electron';
const electronVersion = grep('"electron":', 'package.json')
.sed(/[ ]+"electron": "[\^]?(.*)"[,]?/, '$1')
.replace(/\n/, '');
let nodeGypCmd = `${resolve('node_modules/.bin/node-gyp')} rebuild --arch=x64`;
if (!process.env.NO_ELECTRON) {
const electronUrl = 'https://atom.io/download/electron';
const electronVersion = grep('"electron":', 'package.json')
.sed(/[ ]+"electron": "[\^]?(.*)"[,]?/, '$1')
.replace(/\n/, '');
nodeGypCmd = `${nodeGypCmd} --dist-url=${electronUrl} --target=${electronVersion}`;
}

mkdir('-p', 'modules');
cd('sources/modules');

readdir(resolve()).then((modules) => {
for (const module of modules.filter((module) => statSync(module).isDirectory())) {
cd(module);
exec(`${resolve('../../../node_modules/.bin/node-gyp')} rebuild --arch=x64 --dist-url=${electronUrl} --target=${electronVersion}`);
exec(nodeGypCmd);
mv(`build/Release/${module}.node`, '../../../modules');
rm('-r', 'build');
cd('-');
Expand Down

0 comments on commit 2798c0e

Please sign in to comment.