Merge pull request #7130 from electron/windows-stdin-renderer

Add EOF process.stdin in  render process
This commit is contained in:
Cheng Zhao 2016-09-08 15:04:10 +09:00 committed by GitHub
commit a0eccdfe1e
3 changed files with 37 additions and 19 deletions

View file

@ -39,14 +39,6 @@ if (process.platform === 'win32') {
}
console.log = console.error = console.warn = consoleLog
process.stdout.write = process.stderr.write = streamWrite
// Always returns EOF for stdin stream.
var Readable = require('stream').Readable
var stdin = new Readable()
stdin.push(null)
process.__defineGetter__('stdin', function () {
return stdin
})
}
// Don't quit on fatal error.

View file

@ -38,11 +38,21 @@ if (process.type === 'browser') {
global.setInterval = wrapWithActivateUvLoop(timers.setInterval)
}
// If we're running as a Windows Store app, __dirname will be set
// to C:/Program Files/WindowsApps.
//
// Nobody else get's to install there, changing the path is forbidden
// We can therefore say that we're running as appx
if (process.platform === 'win32' && __dirname.indexOf('\\Program Files\\WindowsApps\\') === 2) {
process.windowsStore = true
if (process.platform === 'win32') {
// Always returns EOF for stdin stream.
const {Readable} = require('stream')
const stdin = new Readable()
stdin.push(null)
process.__defineGetter__('stdin', function () {
return stdin
})
// If we're running as a Windows Store app, __dirname will be set
// to C:/Program Files/WindowsApps.
//
// Nobody else get's to install there, changing the path is forbidden
// We can therefore say that we're running as appx
if (__dirname.indexOf('\\Program Files\\WindowsApps\\') === 2) {
process.windowsStore = true
}
}

View file

@ -221,12 +221,16 @@ describe('node feature', function () {
})
describe('process.stdout', function () {
it('should not throw exception', function () {
process.stdout
it('does not throw an exception when accessed', function () {
assert.doesNotThrow(function () {
process.stdout
})
})
it('should not throw exception when calling write()', function () {
process.stdout.write('test')
it('does not throw an exception when calling write()', function () {
assert.doesNotThrow(function () {
process.stdout.write('test')
})
})
it('should have isTTY defined', function () {
@ -236,6 +240,18 @@ describe('node feature', function () {
})
})
describe('process.stdin', function () {
it('does not throw an exception when accessed', function () {
assert.doesNotThrow(function () {
process.stdin
})
})
it('returns null when read from', function () {
assert.equal(process.stdin.read(), null)
})
})
describe('process.version', function () {
it('should not have -pre', function () {
assert(!process.version.endsWith('-pre'))