@singpath/tools

Singpath package script helpers.

Usage no npm install needed!

<script type="module">
  import singpathTools from 'https://cdn.skypack.dev/@singpath/tools';
</script>

README

Singpath's tools

Singpath package script helpers.

Install

npm install --save-dev @singpath/tools

Usage

exec

const tools = require('@singpath/tools');

// Execute shell command synchronously.
tools.exec('ls -la dist', {
  // by default it will print the command to the stdout
  printCmd: true,

  // by default, the command will inherit the node script stdout;
  // set this property to `true` to ignore the command stdout
  ignoreStdout: false,

  // same for the command stderr
  ignoreStderr: false
});

For more complex usage like piping, try shelljs's exec.

clean


const tools = require('@singpath/tools');

tools.clean(['dist', 'coverage'], {
  // force removing the folders when this is set to `true`
  force: false,

  // info message prefix
  message: 'Removing build/test artifacts'
});

mocha

const tools = require('@singpath/tools');

tools.mocha(my-app/my-app.specs.js, {
  // Mocha ui
  ui: 'bdd'
});

instanbul

const tools = require('@singpath/tools');

tools.instanbul(my-app/my-app.specs.js, {
  // Mocha ui
  ui: 'bdd',

  // path to coverage directory (the directory must exist)
  coverage: path.resolve('./coverage'),

  // instanbul report types
  reports: ['lcov', 'text'],

  // exclude function factory
  exclude: function(baseURL) {
    return function excludeModule(path) {
      return path.startsWith(baseURL + 'jspm_packages') || path.endsWith('specs.js');
    }
  }
});

zip

const tools = require('@singpath/tools');

tools.zip('dist/my-app', 'dist/my-app.zip', {
  // where to save the directory in the archive; uses the directory name
  // by default.
  root: 'my-app'
}).then(
  () => console.log('archive created')
);