Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

jake.exec: don't wrap DOS command in double-quotes #100

Merged
merged 1 commit into from

4 participants

@mpareja

Wrapping in double-quotes is not required by cmd.exe and actually
prevents the command from being executed. For some reason, when the
command is actually executed, the double-quotes are escaped with a
preceding backslash.

Note: I only tested this on an XP virtual machine running on Ubuntu.

@mpareja mpareja jake.exec: don't wrap DOS command in double-quotes
Wrapping in double-quotes is not required by cmd.exe and actually
prevents the command from being executed. For some reason, when the
command is actually executed, the double-quotes are escaped with a
preceding backslash.
0b956a0
@mde mde merged commit 32383be into from
@mde
Owner

Merged, thanks.

@vvs

Ah, thank you for the fix! Essentially, without it jake on Windows is totally hosed, impossible to launch any external commands. It would be nice to have an updated version released for those poor souls who develop node.js apps on Windows.

@mpareja

@vvs No worries! I'm starting to work on a some tools for building .NET apps using jake. Hopefully, I can help fix any other Windows specific issues I find along the way.

@prabirshrestha

@mpareja I have been working with some .net helpers tools. i haven't yet pushed everything online yet though. https://github.com/nJake

Here is the sample https://gist.github.com/1182130

I could share you some ideas I have got.

@mde
Owner

Just pushed a new release. This fix is in v0.2.19.

@mpareja

@prabirshrestha It would be good to mash some of our ideas together. It would be especially useful to share some of the tasks themselves.

At the moment, I'm taking the stance that I don't want paprika to require jake. I may, in the future, release a side-package tailored for working with jake, but I'm not sure that is necessary. I took a quick look at your gist. I'm not convinced that having different methods of defining jake tasks is a good idea. At the moment I'm going with this approach:

var msbuild = require('paprika').msbuild;
task('build', function () {
    msbuild({
        file: '../MySolution.sln'
      , version: 'net35'
      , processor: 'x86'
      , targets: ['Clean', 'Build']
      , properties: { Configuration: 'Release' }
      , show_stdout: false
    });
};

What do you think?

@prabirshrestha

I'm pretty open to the api. This is actually not the main problem. (Your api seems to be much better then mine.)

I have been looking at the best way to solve problems that albacore faces. (Rake tasks for .net https://github.com/derickbailey/Albacore).

What I would like is a official way for anyone to write and distribute custom tasks/modules like msbuild. Jake could then have a wiki page referring to the npm packages. It also doesn't make sense for msbuild task to be distributed in the core jake as some of them may not even be using windows and having tasks such as msubild is also a maintenance headache for @mde when more tasks/modules are created.

@mpareja I would also like to have a default settings so that I don't need to set the version everytime.

var msbuild = require('paprika').msbuild;
msbuild.config({ version: 'net35', processor: 'x86', properties: { Configuration: 'Release' } });

task('build', function () {
    msbuild({
        file: '../MySolution.sln'
      , targets: ['Clean', 'Build']
      , show_stdout: false
    });
};

What we need is a standard way to write/consume jake tasks. So everyone whether a nodejs/java/.net/c++ all can benefit.

I would also sugest adding two options. _command and _parameters.

msbuild({
    _command: 'c:\mono\xbuild.exe',
    _parameters: '/nologo /version'
});

_command and _parameters are additional special options. having _command will allow be to easily use xbuild on mac/linux by compiling with mono. _parameters also makes it easier to support future options or options that are currently not exposed via the msbuild task.

@mpareja

@prabirshrestha - I really like your suggestions for adding _command and _parameters. I'll probably create an issue in paprika. I'll also take a look at adding configurable default settings.

Regarding Albacore: I am planning on taking inspiration from it with regards to what tasks to build (no pun intended) next. Were there some other issues you've seen @derickbailey face with Albacore?

I agree, we need some guidance for publishing reusable tasks(?) for use with jake. Oddly enough, it was through struggling to come up with an API that was inline with the 'jake' way, that I decided not to actually tie paprika to jake. I can always add a 'jake' specific module that leans on paprika in the future. I did look at some of the tasks that come with jake, but I'm not sure I like the constructor approach...

@prabirshrestha

another option that jake needs would be unified logging system and verbosity mode.

This would allow tasks such as msbuild to display the full command path on how it executed msbuild depending on verbosity mode.

@mde
Owner

Added an issue for unified logging, verbose-mode: #102

@prabirshrestha

In the end I landed up creating my own jake helper file for .net related tasks based on @mpareja (https://github.com/mpareja/paprika) syntax

Rather then distributing it as a npm package it is distributed as a single file. http://bit.ly/njakejs

This would be the easiest way to install njake. (This would avoid the use of node_modules folder totally.)

curl -Lk bit.ly/njakejs -o src/njake.js

One downloaded it can be committed to the source control so no package.json file or npm install is required to install njake.

For those that are interested you can find the source code of njake.js at https://github.com/prabirshrestha/njake

Facebook C# SDK now uses jake and njake as the build script which can be found at https://github.com/facebook-csharp-sdk/facebook-csharp-sdk/blob/5bbc18884ca92afae0ed238df874b26b638ca06a/jakefile.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 19, 2012
  1. @mpareja

    jake.exec: don't wrap DOS command in double-quotes

    mpareja authored
    Wrapping in double-quotes is not required by cmd.exe and actually
    prevents the command from being executed. For some reason, when the
    command is actually executed, the double-quotes are escaped with a
    preceding backslash.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 2 deletions.
  1. +1 −2  lib/utils.js
View
3  lib/utils.js
@@ -78,8 +78,7 @@ utils = new (function () {
// Ganking part of Node's child_process.exec to get cmdline args parsed
if (process.platform == 'win32') {
cmd = 'cmd.exe';
- // TODO: Escape double-quotes?
- args = ['/s', '/c', '"' + next + '"'];
+ args = ['/s', '/c', next];
}
else {
cmd = '/bin/sh';
Something went wrong with that request. Please try again.