diff --git a/Gruntfile.js b/Gruntfile.js index 5ca6e86fef1..bb8f01fec17 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,11 +59,12 @@ module.exports = function (grunt) { grunt.registerTask('validate:docs', 'Validates the docs.', function () { const done = this.async(); - const fork = require('child_process').fork, // eslint-disable-line security/detect-child-process + const spawn = require('child_process').spawn, // eslint-disable-line security/detect-child-process path = require('path'), - apidoc = path.join(__dirname, 'apidoc'); + apidoc = path.join(__dirname, 'apidoc'), + cmd = process.platform === 'win32' ? 'tdoc-validate.cmd' : 'tdoc-validate'; - const validate = fork(path.join(__dirname, 'node_modules', '.bin', 'tdoc-validate'), [ apidoc ], { silent: true }); + const validate = spawn(path.join(__dirname, 'node_modules', '.bin', cmd), [ apidoc ], { silent: true }); let output = ''; validate.stderr.on('data', function (data) { diff --git a/build/lib/docs.js b/build/lib/docs.js index 1cfad9f779a..61a460ded02 100644 --- a/build/lib/docs.js +++ b/build/lib/docs.js @@ -17,7 +17,9 @@ class Documentation { } async generateReport(format, filename) { - const args = [ path.join(ROOT_DIR, 'node_modules', '.bin', 'docgen'), '-f', format, '-o', this.outputDir + path.sep, DOC_DIR ]; + const cmd = process.platform === 'win32' ? 'docgen.cmd' : 'docgen'; + const cmdPath = path.join(ROOT_DIR, 'node_modules', '.bin', cmd); + const args = [ '-f', format, '-o', this.outputDir + path.sep, DOC_DIR ]; if (this.hasWindows && format !== 'typescript') { args.push([ '-a', path.join(ROOT_DIR, 'windows/doc/Titanium'), @@ -30,7 +32,7 @@ class Documentation { const outputFile = path.join(this.outputDir, filename); return new Promise((resolve, reject) => { - const prc = spawn('node', args, { cwd: DOC_DIR }); + const prc = spawn(cmdPath, args, { cwd: DOC_DIR }); prc.stdout.on('data', data => console.log(data.toString().trim())); prc.stderr.on('data', data => console.error(data.toString().trim())); prc.on('close', code => {