Skip to content

Instantly share code, notes, and snippets.

@nakosung
Created November 24, 2015 21:21
Show Gist options
  • Save nakosung/1947d83f62352a1a0061 to your computer and use it in GitHub Desktop.
Save nakosung/1947d83f62352a1a0061 to your computer and use it in GitHub Desktop.
(function (global) {
"use strict"
Context.RunFile('polyfill/timers.js')
function npm(command) {
let buffer = ''
// Create a node.js process
let proc = JavascriptProcess.Create(
'c:\\Program Files\\nodejs\\npm.cmd',
command,
false, true, true, 0, `c:\\ue\\testcpp\\Content\\Scripts`, true
)
if (proc) {
let kick = () => {
// read from pipe!
let str = proc.ReadFromPipe()
buffer += str
let lines = buffer.split('\n')
if (lines.length > 1) {
buffer = lines.pop()
lines.forEach((x) => console.log(x))
}
// if process is still running
if (proc.IsRunning()) {
process.nextTick(kick)
}
}
kick()
} else {
console.error("failed to create process")
}
}
global.install = function (p) {
npm(`i ${p} -y`)
}
})(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment