mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-20 15:26:06 +08:00
Enable app/node_modules caching, make postinstall check its Electron version
This commit is contained in:
parent
abb7e3466b
commit
29c89acb60
|
@ -3,7 +3,7 @@ sudo: false
|
|||
language: node_js
|
||||
|
||||
node_js:
|
||||
- '6.9'
|
||||
- '7.10'
|
||||
|
||||
addons:
|
||||
apt:
|
||||
|
@ -43,7 +43,7 @@ before_install:
|
|||
- source app/build/resources/certs/mac/set_unix_env.sh;
|
||||
|
||||
script:
|
||||
- npm run build && npm run upload
|
||||
- npm run build
|
||||
|
||||
deploy:
|
||||
- provider: s3
|
||||
|
@ -62,3 +62,4 @@ deploy:
|
|||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- app/node_modules
|
|
@ -32,7 +32,7 @@ deploy_script:
|
|||
|
||||
environment:
|
||||
matrix:
|
||||
- NODE_VERSION: 6.9
|
||||
- NODE_VERSION: 7.10
|
||||
global:
|
||||
DEBUG: "electron-windows-installer:*,electron-packager:*"
|
||||
SIGN_BUILD: true
|
||||
|
|
|
@ -60,5 +60,8 @@
|
|||
"engines": {
|
||||
"node": "6.9.1",
|
||||
"npm": "3.10.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"rimraf": "^2.6.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
/* eslint global-require: 0 */
|
||||
/* eslint quote-props: 0 */
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const rimraf = require('rimraf');
|
||||
const safeExec = require('./utils/child-process-wrapper.js').safeExec;
|
||||
|
||||
const npmElectronTarget = require('../app/package.json').dependencies.electron;
|
||||
const npmEnvs = {
|
||||
system: process.env,
|
||||
electron: Object.assign({}, process.env, {
|
||||
'npm_config_target': require('../app/package.json').dependencies.electron,
|
||||
'npm_config_target': npmElectronTarget,
|
||||
'npm_config_arch': process.arch,
|
||||
'npm_config_target_arch': process.arch,
|
||||
'npm_config_disturl': 'https://atom.io/download/atom-shell',
|
||||
|
@ -31,5 +34,26 @@ function npm(cmd, options) {
|
|||
});
|
||||
}
|
||||
|
||||
npm('install', {cwd: './app', env: 'electron'})
|
||||
.then(() => npm('dedupe', {cwd: './app', env: 'electron'}))
|
||||
async function go() {
|
||||
// For speed, we cache app/node_modules. However, we need to
|
||||
// be sure to do a full rebuild of native node modules when the
|
||||
// Electron version changes. To do this we check a marker file.
|
||||
const cacheVersionPath = './app/node_modules/.postinstall-target-version';
|
||||
const cacheElectronTarget = fs.existsSync(cacheVersionPath) && fs.readFileSync(cacheVersionPath).toString();
|
||||
|
||||
if (cacheElectronTarget !== npmElectronTarget) {
|
||||
console.log(`\n-- Clearing app/node_modules --`)
|
||||
rimraf.sync(path.resolve(__dirname, '..', 'app', 'node_modules'));
|
||||
}
|
||||
|
||||
// run `npm install` in ./app with Electron NPM config
|
||||
await npm('install', {cwd: './app', env: 'electron'});
|
||||
|
||||
// run `npm dedupe` in ./app with Electron NPM config
|
||||
await npm('dedupe', {cwd: './app', env: 'electron'});
|
||||
|
||||
// write the marker with the electron version
|
||||
fs.writeFileSync(cacheVersionPath, npmElectronTarget);
|
||||
}
|
||||
|
||||
go();
|
||||
|
|
Loading…
Reference in a new issue