diff --git a/spec/buffered-node-process-spec.coffee b/spec/buffered-node-process-spec.coffee new file mode 100644 index 000000000..1ea6074c5 --- /dev/null +++ b/spec/buffered-node-process-spec.coffee @@ -0,0 +1,39 @@ +path = require 'path' +BufferedNodeProcess = require '../src/buffered-node-process' + +describe "BufferedNodeProcess", -> + it "executes the script in a new process", -> + exit = jasmine.createSpy('exitCallback') + output = '' + stdout = (lines) -> output += lines + error = '' + stderr = (lines) -> error += lines + args = ['hi'] + command = path.join(__dirname, 'fixtures', 'script.js') + + new BufferedNodeProcess({command, args, stdout, stderr, exit}) + + waitsFor -> + exit.callCount is 1 + + runs -> + expect(output).toBe 'hi' + expect(error).toBe '' + expect(args).toEqual ['hi'] + + it "suppresses deprecations in the new process", -> + exit = jasmine.createSpy('exitCallback') + output = '' + stdout = (lines) -> output += lines + error = '' + stderr = (lines) -> error += lines + command = path.join(__dirname, 'fixtures', 'script-with-deprecations.js') + + new BufferedNodeProcess({command, stdout, stderr, exit}) + + waitsFor -> + exit.callCount is 1 + + runs -> + expect(output).toBe 'hi' + expect(error).toBe '' diff --git a/spec/fixtures/script-with-deprecations.js b/spec/fixtures/script-with-deprecations.js new file mode 100644 index 000000000..4abe4774a --- /dev/null +++ b/spec/fixtures/script-with-deprecations.js @@ -0,0 +1,2 @@ +require('fs').existsSync('hi'); +process.stdout.write('hi'); diff --git a/spec/fixtures/script.js b/spec/fixtures/script.js new file mode 100644 index 000000000..94972dfb5 --- /dev/null +++ b/spec/fixtures/script.js @@ -0,0 +1 @@ +process.stdout.write(process.argv[2]); diff --git a/src/buffered-node-process.coffee b/src/buffered-node-process.coffee index e9a3fbee4..bb1a1c655 100644 --- a/src/buffered-node-process.coffee +++ b/src/buffered-node-process.coffee @@ -48,5 +48,8 @@ class BufferedNodeProcess extends BufferedProcess options.env ?= Object.create(process.env) options.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = 1 + args = args?.slice() ? [] args.unshift(command) + args.unshift('--no-deprecation') + super({command: node, args, options, stdout, stderr, exit})