Skip to content

Commit

Permalink
Merge pull request #7 from Briaker/master
Browse files Browse the repository at this point in the history
Added some extra options
  • Loading branch information
super-cache-money authored Oct 12, 2022
2 parents 4f72273 + aa5be9f commit 22cd416
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ require('make-runnable/custom')({
})
```

### Remove printed output
You can pass in a custom option to `make-runnable` to hide the output message and frame generated by `make-runnable`:
```
require('make-runnable/custom')({
printOutput: false
})
```

### Remove printed errors
You can pass in a custom option to `make-runnable` to hide error messages and frames generated by `make-runnable`:
```
require('make-runnable/custom')({
printErrorOutput: false
})
```

### Pass in multiple objects to the function being called

While you can pass a *single* object, or multiple *primitives*, multiple objects are not currently supported. PRs welcome!
While you can pass a *single* object, or multiple *primitives*, multiple objects are not currently supported. PRs welcome!
20 changes: 13 additions & 7 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,38 @@ var requiringModule = module.parent.parent;
module.exports = function(inputOptions) {

var defaultOptions = {
printOutputFrame: true
printOutputFrame: true,
printOutput: true,
printErrorOutput: true
};

var options = mergeObjects(defaultOptions, inputOptions || {});

function printOutput(returnValue) {
Bluebird.resolve(returnValue)
.then(function (output) {
if (options.printOutputFrame) {
console.log('--------make-runnable-output--------');
}
console.log(output);
if (options.printOutputFrame) {
console.log('------------------------------------');
if (options.printOutput) {
if (options.printOutputFrame) {
console.log('--------make-runnable-output--------');
}
console.log(output);
if (options.printOutputFrame) {
console.log('------------------------------------');
}
}
}).catch(printError);
}

function printError(error) {
if (printErrorOutput) {
if (options.printOutputFrame) {
console.log('--------make-runnable-error--------');
}
console.log(error);
if (options.printOutputFrame) {
console.log('------------------------------------');
}
}
}

// if the requiring file is being run directly from the command line
Expand Down

0 comments on commit 22cd416

Please sign in to comment.