UNPKG

newkit-cli

Version:

Newkit cli tools.

36 lines (32 loc) 940 B
'use strict'; let fs = require('fs'); let path = require('path'); let child_process = require('child_process'); let linter = require('linter-hodgepodge'); let util = require('./util'); let destPath = './dist/jshint-output.html'; module.exports = (module) => { let cwd = process.cwd(); if (!fs.existsSync(`./src/modules/${module}`)) { util.error('Module folder is not found.'); return; } if (!fs.existsSync('./dist')) { fs.mkdirSync('./dist'); } linter .jshint([ `./src/modules/${module}/**/*.js`, `!./src/modules/${module}/+(vendor*|libs*)/**` ], {}) .reporterAsFile(destPath); let startPath = path.join(cwd, destPath); child_process.exec(`start ${startPath}`, {}, (error, stdout, stderr) => { if (error) { console.log('Exec error', error); return; } stdout && console.log(stdout); stderr && console.log(stderr); }); };