Open ainthek opened 8 years ago
came up with this solution for now:
//see: http://www.graspjs.com/docs/lib/
/*
// option1: use all from cli and override with your own
var args = Object.assign(require('grasp/lib/options.js').parse(process.argv), {
replaceFunc: replaceFunc
});
*/
// option2: use explicit args and only files from cli
var args = {
recursive: true,
extensions: ['js'],
parser: ['acorn', {
locations: true,
ecmaVersion: 6,
sourceType: 'module',
allowHashBang: true
}],
lineNumber: true,
color: true,
_: ['obj!>prop[key=("$schema")][val="http://json-schema.org/draft-03/schema#"]']
// only file taken from CLI
.concat(process.argv.slice(2)),
// and replace function
replaceFunc: replaceFunc
}
require('grasp')({
args: args,
exit: process.exit,
stdin: process.stdin,
callback: console.log,
error: console.error
});
function replaceFunc(getRaw, node, query, named) {
//console.log(arguments);
console.log(getRaw(node));
return "slon";
}
please can you provide example how to use all parameters from CLI and override only replaceFunc ?
its seems impossible to me.