kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

Add package.json bin command #93

Closed kungfooman closed 5 months ago

kungfooman commented 7 months ago

Example from @babel/parser:

#!/usr/bin/env node
/* eslint no-var: 0 */

var parser = require("..");
var fs = require("fs");

var filename = process.argv[2];
if (!filename) {
  console.error("no filename specified");
} else {
  var file = fs.readFileSync(filename, "utf8");
  var ast = parser.parse(file);

  console.log(JSON.stringify(ast, null, "  "));
}

package.json

  "bin": "./bin/babel-parser.js",

Then you can use it like:

npx @babel/parser test.js