Skip to content

Instantly share code, notes, and snippets.

@grabbou
Created September 30, 2015 13:49
Show Gist options
  • Save grabbou/83e5601b2eb71ea0ab31 to your computer and use it in GitHub Desktop.
Save grabbou/83e5601b2eb71ea0ab31 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
// Deps
var chain = require('slide').chain;
var path = require('path');
var ln = require('linklocal');
var exec = require('./exec');
var program = require('commander');
var linklocal = require('linklocal');
// Paths
var webPath = path.join(__dirname, '../web');
var nativePath = path.join(__dirname, '../native');
var commonPath = path.join(__dirname, '../common');
/**
* Steps:
* 1. cd ./common && npm install
* 2. cd ./web && linklocal
* 3. cd ./native && linklocal
* 4. cd ./web && npm install
* 5. cd ./native && npm install
* 6. cd ./web && npm build
*/
program
.command('postinstall')
.description('Links packages and installs their dependencies')
.action(function() {
chain([
[exec, 'npm install', commonPath],
[ln, webPath],
[ln, nativePath],
[exec, 'npm install', webPath],
[exec, 'npm install', nativePath],
[exec, 'npm run build', webPath]
], function(err) {
if (err) console.log(err);
})
});
program
.command('start')
.action(function postInstall() {
console.log('Use web-start to start web server instead');
});
/**
* Steps:
* 1. cd ./web && npm start
*/
program
.command('web-start')
.description('Starts web server')
.action(function postInstall() {
exec('npm start', webPath);
});
/**
* Steps:
* 1. cd ./web && npm run start-dev
*/
program
.command('web-start-dev')
.description('Starts web server')
.action(function() {
exec('npm run start-dev', webPath);
});
/**
* Steps:
* 1. cd ./web && npm run build
*/
program
.command('web-build')
.description('Starts web server')
.action(function() {
exec('npm run build', webPath);
});
/**
* Steps:
* 1. cd ./web && npm test
*/
program
.command('test')
.description('Starts web server')
.action(function() {
exec('npm test', webPath);
});
program.parse(process.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment