sails-script

0.0.1 • Public • Published

sails-script

CLI to run scripts within the sails environment.

Installation

npm install sails-script -g

Requirements

Running within a sails project.

Usage

Given scripts/Example.js is your script to run,

sails-script scripts/Example.js

Script

Your script should export a function that either takes a callback as as an argument or returns a promise. If your script takes a callback as an argument, the callback can take a single error argument.

callback example

module.exports = function(cb){
  User.find({}).then(users => {
    console.log(users);
    cb();
  }).catch(err => {
    cb(err);
  });
}

promise example

module.exports = function(){
  return new Promise(async (resolve, reject) => {
    let users = await User.find({});
    console.log(users);
    resolve();
  });
}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i sails-script

      Weekly Downloads

      0

      Version

      0.0.1

      License

      ISC

      Unpacked Size

      2.36 kB

      Total Files

      4

      Last publish

      Collaborators

      • frostme