Created
November 24, 2015 21:21
-
-
Save nakosung/1947d83f62352a1a0061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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