Skip to content

Instantly share code, notes, and snippets.

@ChrisVilches
Last active July 4, 2017 12:43
Show Gist options
  • Save ChrisVilches/5f5738e60214470ddaed3932ab7501ba to your computer and use it in GitHub Desktop.
Save ChrisVilches/5f5738e60214470ddaed3932ab7501ba to your computer and use it in GitHub Desktop.
Sails.js v1.0: npm run gruntless (lift app without grunt)

I have a heavy grunt setup, so when I'm only working on the backend, I run the app with this command

npm run gruntless

Here's how to make it:

app.js

var args = process.argv.slice(2);
function hasArg(arg){
  return args.indexOf(arg) != -1;
}

var sails;
var rc;
Sails = require('sails').constructor;
rc = require('sails/accessible/rc');
sails = new Sails();

if(hasArg('--no-grunt')){
  sails.log('Running with --no-grunt switch');
  sails.lift({hooks: { grunt: false }}); // The important line
} else {
  sails.lift(rc('sails')); // A normal lift
}

package.json

"scripts": {
    ...
    "gruntless": "node app.js --no-grunt",
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment