aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/nodejs
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2014-04-01 11:51:46 -0400
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-04-15 18:54:24 +0200
commit5877328c4dacb1283408083cb3538ea5bc46eae5 (patch)
tree1c0047b2a0a3d9ce38a7e49fb4bff84242baccf9 /share/qbs/modules/nodejs
parentad533a593f0883f2a6e3362c2254afe4e0d5cf64 (diff)
Add support for running Node.js using qbs run.
Change-Id: I98a38e49cbea57d44b787eec12c2cb5f2e5cd601 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'share/qbs/modules/nodejs')
-rw-r--r--share/qbs/modules/nodejs/NodeJS.qbs56
1 files changed, 56 insertions, 0 deletions
diff --git a/share/qbs/modules/nodejs/NodeJS.qbs b/share/qbs/modules/nodejs/NodeJS.qbs
new file mode 100644
index 000000000..24a22d6de
--- /dev/null
+++ b/share/qbs/modules/nodejs/NodeJS.qbs
@@ -0,0 +1,56 @@
+import qbs
+import qbs.File
+import qbs.FileInfo
+import qbs.ModUtils
+
+Module {
+ // JavaScript files which have been "processed" - currently this simply means "copied to output
+ // directory" but might later include minification and obfuscation processing
+ additionalProductTypes: ["nodejs_processed_js"]
+
+ property path applicationFile
+ PropertyOptions {
+ name: "applicationFile"
+ description: "file whose corresponding output will be executed when running the Node.js app"
+ }
+
+ setupRunEnvironment: {
+ var v = new ModUtils.EnvironmentVariable("NODE_PATH", qbs.pathListSeparator, qbs.hostOS.contains("windows"));
+ // can't use product.buildDirectory here, but RunEnvironment always sets the working
+ // directory to the directory containing the target file so we can exploit this for now
+ v.prepend(".");
+ v.set();
+ }
+
+ FileTagger {
+ patterns: ["*.js"]
+ fileTags: ["js"]
+ }
+
+ Rule {
+ inputs: ["js"]
+
+ outputArtifacts: {
+ var tags = ["nodejs_processed_js"];
+ if (input.fileTags.contains("application_js") ||
+ product.moduleProperty("nodejs", "applicationFile") === input.filePath)
+ tags.push("application");
+
+ return [{
+ filePath: product.destinationDirectory + '/' + input.fileName,
+ fileTags: tags
+ }];
+ }
+
+ outputFileTags: ["nodejs_processed_js", "application"]
+
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "copying " + FileInfo.fileName(input.filePath);
+ cmd.sourceCode = function() {
+ File.copy(input.filePath, output.filePath);
+ };
+ return cmd;
+ }
+ }
+}