Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3D76D1084D for ; Sun, 5 Jan 2014 06:33:22 +0000 (UTC) Received: (qmail 47039 invoked by uid 500); 5 Jan 2014 06:33:14 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 46950 invoked by uid 500); 5 Jan 2014 06:33:08 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 46861 invoked by uid 99); 5 Jan 2014 06:32:57 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jan 2014 06:32:57 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2C5954429A; Sun, 5 Jan 2014 06:32:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Sun, 05 Jan 2014 06:32:57 -0000 Message-Id: <264537e6659142d5b31aa855d5d985a5@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: [flex-utilities] [refs/heads/develop] - Fix bugs in exec task Fix bugs in exec task Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/0ed7eeca Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/0ed7eeca Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/0ed7eeca Branch: refs/heads/develop Commit: 0ed7eeca4622697a054f793191a30faeed2a135d Parents: 15de317 Author: Alex Harui Authored: Sat Jan 4 22:30:32 2014 -0800 Committer: Alex Harui Committed: Sat Jan 4 22:30:32 2014 -0800 ---------------------------------------------------------------------- ant_on_air/src/org/apache/flex/ant/tags/Exec.as | 39 ++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0ed7eeca/ant_on_air/src/org/apache/flex/ant/tags/Exec.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Exec.as b/ant_on_air/src/org/apache/flex/ant/tags/Exec.as index f30e68d..bc503a6 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/Exec.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/Exec.as @@ -24,8 +24,6 @@ package org.apache.flex.ant.tags import flash.events.NativeProcessExitEvent; import flash.events.ProgressEvent; import flash.filesystem.File; - import flash.filesystem.FileMode; - import flash.filesystem.FileStream; import flash.system.Capabilities; import flash.utils.IDataInput; @@ -56,6 +54,8 @@ package org.apache.flex.ant.tags var ok:Boolean = false; for each (var p:String in osArr) { + if (p.toLowerCase() == "windows") + p = "win"; if (thisOS.indexOf(p.toLowerCase()) != -1) { ok = true; @@ -78,13 +78,26 @@ package org.apache.flex.ant.tags args.push("/c"); if (numChildren > 0) { - var arg:Arg = getChildAt(0) as Arg; - arg.setContext(context); - args.push(fileName + " " + arg.value); + var cmdline:String = fileName; + for (var i:int = 0; i < numChildren; i++) + { + var arg:Arg = getChildAt(i) as Arg; + arg.setContext(context); + cmdline += " " + quoteIfNeeded(arg.value); + } + args.push(cmdline); } else args.push(fileName); nativeProcessStartupInfo.arguments = args; + if (dir) + { + var wd:File; + wd = File.applicationDirectory; + wd = wd.resolvePath(dir); + nativeProcessStartupInfo.workingDirectory = wd; + } + process = new NativeProcess(); process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData); process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onOutputErrorData); @@ -94,6 +107,11 @@ package org.apache.flex.ant.tags return false; } + private function get dir():String + { + return getNullOrAttributeValue("@dir"); + } + private function get fileName():String { return getAttributeValue("@executable"); @@ -129,8 +147,15 @@ package org.apache.flex.ant.tags var data:String = stdOut.readUTFBytes(process.standardOutput.bytesAvailable); trace("Got: ", data); if (outputProperty) - context[outputProperty] = data; + context[outputProperty] = StringUtil.trim(data); + } + + private function quoteIfNeeded(s:String):String + { + // has spaces but no quotes + if (s.indexOf(" ") != -1 && s.indexOf('"') == -1) + return '"' + s + '"'; + return s; } - } } \ No newline at end of file