diff --git a/.gitignore b/.gitignore index 79fbf7c..a72b52e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ lib-cov pids logs results -lib npm-debug.log node_modules diff --git a/lib/rcedit.js b/lib/rcedit.js new file mode 100644 index 0000000..fadfecd --- /dev/null +++ b/lib/rcedit.js @@ -0,0 +1,56 @@ +var pairSettings, path, singleSettings, spawn; + +path = require('path'); + +spawn = require('child_process').spawn; + +pairSettings = ['version-string']; + +singleSettings = ['file-version', 'product-version', 'icon']; + +module.exports = function(exe, options, callback) { + var args, child, error, key, name, rcedit, stderr, value, _i, _j, _len, _len1, _ref; + rcedit = path.resolve(__dirname, '..', 'bin', 'rcedit.exe'); + args = [exe]; + for (_i = 0, _len = pairSettings.length; _i < _len; _i++) { + name = pairSettings[_i]; + if (options[name] != null) { + _ref = options[name]; + for (key in _ref) { + value = _ref[key]; + args.push("--set-" + name); + args.push(key); + args.push(value); + } + } + } + for (_j = 0, _len1 = singleSettings.length; _j < _len1; _j++) { + name = singleSettings[_j]; + if (options[name] != null) { + args.push("--set-" + name); + args.push(options[name]); + } + } + if (process.platform !== "win32") { + args.unshift(rcedit); + rcedit = "wine"; + } + child = spawn(rcedit, args); + stderr = ''; + error = null; + child.on('error', function(err) { + return error != null ? error : error = err; + }); + child.stderr.on('data', function(data) { + return stderr += data; + }); + return child.on('close', function(code) { + if (error != null) { + return callback(error); + } else if (code === 0) { + return callback(null); + } else { + return callback(stderr); + } + }); +}; diff --git a/src/rcedit.coffee b/src/rcedit.coffee deleted file mode 100644 index 3ab73cb..0000000 --- a/src/rcedit.coffee +++ /dev/null @@ -1,39 +0,0 @@ -path = require 'path' -{spawn} = require 'child_process' - -pairSettings = ['version-string'] -singleSettings = ['file-version', 'product-version', 'icon'] - -module.exports = (exe, options, callback) -> - rcedit = path.resolve __dirname, '..', 'bin', 'rcedit.exe' - args = [exe] - - for name in pairSettings - if options[name]? - for key, value of options[name] - args.push "--set-#{name}" - args.push key - args.push value - - for name in singleSettings - if options[name]? - args.push "--set-#{name}" - args.push options[name] - - if process.platform != "win32" - args.unshift(rcedit) - rcedit = "wine" - - child = spawn rcedit, args - - stderr = '' - error = null - child.on 'error', (err) -> error ?= err - child.stderr.on 'data', (data) -> stderr += data - child.on 'close', (code) -> - if error? - callback error - else if code is 0 - callback null - else - callback stderr