npm.io
0.2.0 • Published 9 years agoCLI

check-syntax

Licence
MIT
Version
0.2.0
Deps
1
Vulns
0
Weekly
0

check-syntax

Checks the syntax of an entry point and it's (application-level) dependencies as per the currently installed Node version.

About

The node -c command allows us to check the syntax of a single file.

The check-syntax module allows us to check the syntax of all the files in a dependency tree (excluding any dependencies in the node_modules folder).

CLI

Install
npm install -g check-syntax
Use
check-syntax <entry-point>

API

Install
npm install check-syntax
Use
var checkSyntax = require('check-syntax')
var someEntryPoint = 'my/js/file.js'
console.log(checkSyntax(someEntryPoint)) // outputs an array of objects, {loc, code, msg}
Reporter

To use the CLI reporter programatically:

var report = require('check-syntax/report')
var someEntryPoint = 'my/js/file.js'
report(someEntryPoint) // same as output as check-syntax command, will exit immediately 

If a pass callback is supplied, the process won't exit but instead will call the callback with the first arg set to either true or false based on whether the syntax check was successful.

report(someEntryPoint, (pass) => {
  if (pass) console.log('hooray')
  else console.log('boo')
})
License

MIT