From e952a68c960697fb35b0ae4fec5ea43243f14a77 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 14:53:09 -0800 Subject: [PATCH] Support setting working directory of child process --- native/v8_extensions/native.mm | 5 +++++ spec/stdlib/child-process-spec.coffee | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/native/v8_extensions/native.mm b/native/v8_extensions/native.mm index 9ce5b4ee6..9ce163a30 100644 --- a/native/v8_extensions/native.mm +++ b/native/v8_extensions/native.mm @@ -485,6 +485,11 @@ namespace v8_extensions { }; } + CefRefPtr currentWorkingDirectory = options->GetValue("cwd"); + if (!currentWorkingDirectory->IsUndefined() && !currentWorkingDirectory->IsNull()) { + [task setCurrentDirectoryPath:stringFromCefV8Value(currentWorkingDirectory)]; + } + [task launch]; return true; diff --git a/spec/stdlib/child-process-spec.coffee b/spec/stdlib/child-process-spec.coffee index 15b9be963..e0e002f00 100644 --- a/spec/stdlib/child-process-spec.coffee +++ b/spec/stdlib/child-process-spec.coffee @@ -127,3 +127,18 @@ describe 'Child Processes', -> runs -> expect(output.length).toBeGreaterThan 1 + + describe "when the cwd option is set", -> + it "runs the task from the specified current working directory", -> + output = [] + + waitsForPromise -> + options = + cwd: fixturesProject.getPath() + stdout: (data) -> output.push(data) + stderr: (data) -> + + ChildProcess.exec("pwd", options) + + runs -> + expect(output.join('')).toBe "#{fixturesProject.getPath()}\n"