[tests] move test scripts into js (bin folder) - now works cross platform

This commit is contained in:
Salakar 2017-09-25 11:32:18 +01:00
parent 261edf7a83
commit 6aaafc5995
2 changed files with 56 additions and 3 deletions

52
bin/test.js Normal file
View File

@ -0,0 +1,52 @@
const shell = require('shelljs');
const WATCH_SRC = require('path').resolve('./lib');
const WATCH_OUT = require('path').resolve('./tests/firebase');
/*
"tests-watch-init": "wml add $(node --eval \"console.log(require('path').resolve('./lib'));\") $(node --eval \"console.log(require('path').resolve('./tests/firebase'));\")",
"tests-watch-start": "watchman watch $(node --eval \"console.log(require('path').resolve('./lib'));\") && wml start",
"tests-watch-stop": "watchman watch-del $(node --eval \"console.log(require('path').resolve('./lib'));\") && wml stop"
*/
if (process.argv.includes('watch')) {
if (!shell.which('wml')) {
shell.echo('');
shell.echo('---------------------------------------------------');
shell.echo(' Missing required npm global from library wix/wml. ');
shell.echo('---------------------------------------------------');
shell.echo('');
shell.exit(1);
}
if (!shell.which('watchman')) {
shell.echo('');
shell.echo('---------------------------------------------------');
shell.echo(' Missing required executable: watchman ');
shell.echo('---------------------------------------------------');
shell.echo('');
shell.exit(1);
}
if (process.argv.includes('init')) {
console.log(`wml add ${WATCH_SRC} ${WATCH_OUT}`);
if (shell.exec(`wml add ${WATCH_SRC} ${WATCH_OUT}`).code !== 0) {
shell.echo('Error setting up watched location via WML.');
shell.exit(1);
}
}
if (process.argv.includes('start')) {
console.log(`watchman watch ${WATCH_SRC} && wml start`);
const watcher = shell.exec(`watchman watch ${WATCH_SRC} && wml start`, { async: true });
watcher.stdout.on('data', console.log);
watcher.stderr.on('data', console.error);
}
if (process.argv.includes('stop')) {
console.log(`watchman watch-del ${WATCH_SRC} && wml stop && wml rm all`);
const watcher = shell.exec(`watchman watch-del ${WATCH_SRC} && wml stop && wml rm all`, { async: true });
watcher.stdout.on('data', console.log);
watcher.stderr.on('data', console.error);
}
}

View File

@ -11,12 +11,12 @@
"build": "./node_modules/.bin/babel --source-maps=true --out-dir=dist .",
"publish_pages": "gh-pages -d public/",
"docs-serve-local": "docsify serve docs",
"test-cli": "node ./bin/test.js",
"tests-packager": "cd tests && npm run start",
"tests-npm-install": "cd tests && npm install",
"tests-pod-install": "cd tests && npm run ios:pod:install",
"tests-watch-init": "wml add $(node --eval \"console.log(require('path').resolve('./lib'));\") $(node --eval \"console.log(require('path').resolve('./tests/firebase'));\")",
"tests-watch-start": "watchman watch $(node --eval \"console.log(require('path').resolve('./lib'));\") && wml start",
"tests-watch-stop": "watchman watch-del $(node --eval \"console.log(require('path').resolve('./lib'));\") && wml stop"
"tests-watch-start": "npm run test-cli watch init start",
"tests-watch-stop": "npm run test-cli watch stop"
},
"repository": {
"type": "git",
@ -74,6 +74,7 @@
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-native": "^0.44.0",
"shelljs": "^0.7.8",
"wml": "0.0.82"
},
"dependencies": {