File: exec.js

package info (click to toggle)
node-command-join 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 124 kB
  • ctags: 4
  • sloc: makefile: 7; sh: 2
file content (19 lines) | stat: -rw-r--r-- 513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict'

const join = require('../')
const ChildProcess = require('child_process')

if (require.main === module) {
  console.log(process.argv.slice(2).join('\n'))
}
else if (typeof ChildProcess.execSync === 'function') {
  module.exports = function exec(args) {
    args = args.slice()
    args.unshift(__filename)
    let joined = join(args)
    let command = `nodejs ${joined}`
    let out = ChildProcess.execSync(command)
    // trim to remove extra \n appended by cmd
    return String(out).trim()
  }
}