UNPKG

544 BJavaScriptView Raw
1'use strict';
2
3const isLocal = process.argv[2] === 'local';
4
5/**
6 * A simple helper for running a function if `local` is passed as argument
7 * @example
8 * // test.js
9 * const { localRun } = require('kes');
10 * localRun(() => {
11 * console.log('my function');
12 * });
13 * // result
14 * // $ node test.js local
15 * // my function
16 *
17 * @param {Function} func A javascript function
18 * @return {Object} returns the result of the function call
19 */
20module.exports.localRun = (func) => {
21 if (isLocal) {
22 // Run the function
23 return func();
24 }
25};