diff options
author | adam <anton@adamansky.com> | 2013-05-02 01:23:15 +0700 |
---|---|---|
committer | adam <anton@adamansky.com> | 2013-05-02 01:23:15 +0700 |
commit | a4dbe9377a3174885c7a9523c442c8eb0206d997 (patch) | |
tree | 1f1b4acc590a4a41b50d153bb5ef3a9e9fe521aa | |
parent | f8d800fbf292c7256270967185d62e3f4ee11b10 (diff) | |
download | ejdb-a4dbe9377a3174885c7a9523c442c8eb0206d997.tar.gz ejdb-a4dbe9377a3174885c7a9523c442c8eb0206d997.tar.bz2 ejdb-a4dbe9377a3174885c7a9523c442c8eb0206d997.zip |
#61 fixed
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .npmignore | 1 | ||||
-rw-r--r-- | binding.gyp | 4 | ||||
-rw-r--r-- | node/platform.js | 50 | ||||
-rw-r--r-- | package.json | 5 |
5 files changed, 48 insertions, 13 deletions
@@ -23,6 +23,7 @@ .dep.inc /ejdbdll /node_modules +/configure.gypi addressbook* autom4te.cache/ @@ -28,6 +28,7 @@ */nbproject/private/* /ejdbdll /node_modules +/configure.gypi addressbook* /.idea/workspace.xml diff --git a/binding.gyp b/binding.gyp index b76cca3..db76243 100644 --- a/binding.gyp +++ b/binding.gyp @@ -24,9 +24,7 @@ }, 'conditions': [ ['OS == "win"', { - 'variables': { - 'EJDB_HOME%': 'C:/EJDB' - }, + 'includes': ['configure.gypi'], 'defines': [ '_UNICODE', ], diff --git a/node/platform.js b/node/platform.js index 4f0b5a1..456189a 100644 --- a/node/platform.js +++ b/node/platform.js @@ -5,7 +5,6 @@ var fs = require("fs"); var path = require("path"); var http = require("http"); var util = require("util"); -var AdmZip = require("adm-zip"); if (process.platform === "win32") { win(); @@ -15,7 +14,7 @@ if (process.platform === "win32") { function exithandler(cmd, cb) { return function(code) { - if (code !== 0) { + if (code != null && code !== 0) { console.log("" + cmd + " process exited with code " + code); process.exit(code); } @@ -106,8 +105,8 @@ function win() { process.stdout.write("."); }); res.on("end", function() { - console.log("\n%d bytes downloaded", len); - processArchive(); + console.log("\n%d bytes received", len); + setTimeout(processArchive, 2000); }); res.pipe(wf); }); @@ -117,17 +116,54 @@ function win() { } function processArchive() { + var AdmZip = require("adm-zip"); console.log("Unzip archive '%s'", zfile); var azip = new AdmZip(zfile); azip.extractAllTo(sdir, true); sdir = path.resolve(sdir); - var args = ["rebuild", util.format("-DEJDB_HOME=%s", sdir)]; + + var config = {}; + config["variables"] = { + "EJDB_HOME" : sdir + }; + fs.writeFileSync("configure.gypi", JSON.stringify(config)); + + var args = ["configure", "rebuild"]; console.log("node-gyp %j", args); - var ng = spawn("node-gyp", args, {stdio : "inherit"}); - ng.on("close", exithandler("node-gyp")); + var ng = spawn("node-gyp.cmd", args, {stdio : "inherit"}); + ng.on("error", function(ev) { + console.log("Spawn error: " + ev); + process.exit(1); + }); + ng.on("close", exithandler("node-gyp", function() { + copyFile(path.join(sdir, "lib/tcejdbdll.dll"), + "build/Release/tcejdbdll.dll", + exithandler("copy tcejdbdll.dll")); + })); } } } +} +function copyFile(source, target, cb) { + var cbCalled = false; + var rd = fs.createReadStream(source); + rd.on("error", function(err) { + done(err); + }); + var wr = fs.createWriteStream(target); + wr.on("error", function(err) { + done(err); + }); + wr.on("close", function(ex) { + done(); + }); + rd.pipe(wr); + function done(err) { + if (!cbCalled) { + cb(err); + cbCalled = true; + } + } }
\ No newline at end of file diff --git a/package.json b/package.json index 00c4fd8..96744dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "ejdb", - "version" : "1.1.3-1", + "version" : "1.1.3-2", "config" : { "windownloadurl" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.3-mingw32-i686.zip" }, @@ -33,8 +33,7 @@ "node" : "0.8.x || 0.10.x" }, "dependencies" : { - "nodeunit" : ">=0.7.0", - "adm-zip" : "*" + "nodeunit" : ">=0.7.0" }, "scripts" : { "preinstall" : "node node/platform.js preinstall", |