Merge pull request #2410 from toolness/npm-explore-for-windows

Make "npm run build" work on Windows.
This commit is contained in:
Mike Kamermans 2015-07-16 12:19:35 -07:00
Родитель 798863d31a 3c0f970de6
Коммит 3f21f1604f
2 изменённых файлов: 36 добавлений и 2 удалений

34
npm_tasks/explore.js Normal file
Просмотреть файл

@ -0,0 +1,34 @@
// This is meant to provide a cross-platform way of doing the same thing
// as "npm explore <name> -- <cmd>" (which doesn't work on Windows; see
// https://github.com/npm/npm/issues/8932).
//
// Note that <cmd> is expected to be something extremely simple like
// "npm install" or "git pull origin master". It shouldn't contain any
// quoted arguments or other funky things.
var fs = require('fs');
var path = require('path');
var execSync = require('child_process').execSync;
var ROOT_DIR = path.resolve(__dirname, '..');
function getModuleDir(moduleName) {
return fs.realpathSync(path.resolve(ROOT_DIR, 'node_modules', moduleName));
}
function explore(moduleName, cmd) {
execSync(cmd, { cwd: getModuleDir(moduleName), stdio: 'inherit' });
}
function main() {
if (process.argv.length < 5 || process.argv[3] != '--') {
console.log("usage: " + path.basename(process.argv[1]) +
" <name> -- <cmd>");
process.exit(1);
}
explore(process.argv[2], process.argv.slice(4).join(' '));
}
if (!module.parent) {
main();
}

Просмотреть файл

@ -4,8 +4,8 @@
"description": "Webmaker for Android.",
"scripts": {
"start": "npm run build",
"build": "npm explore webmaker-core -- npm install && npm run copy:env && npm run build:core && npm run copy:core",
"build:core": "npm explore webmaker-core -- npm run build",
"build": "node npm_tasks/explore.js webmaker-core -- npm install && npm run copy:env && npm run build:core && npm run copy:core",
"build:core": "node npm_tasks/explore.js webmaker-core -- npm run build",
"copy:core": "rimraf app/src/main/assets/www/ && mkdirp app/src/main/assets/www/ && ncp node_modules/webmaker-core/dest/ app/src/main/assets/www/",
"copy:env": "node npm_tasks/copy-env.js"
},