Skip to content
This repository
Browse code

tweaks for NPM publishing

  • Loading branch information...
commit 913949ffaebe8675add84fe8b72d38bd4e3f72b3 1 parent fe48484
Christoph Dorn authored September 30, 2011
6  package.json
@@ -5,6 +5,7 @@
5 5
     "label": "CommonJS Module Loader",
6 6
     "description": "Versatile & Complete Cross-Platform CommonJS JavaScript Module, Package & Program Loader",
7 7
     "homepage": "https://github.com/pinf/loader-js",
  8
+    "author": "Christoph Dorn (http://www.christophdorn.com/) <christoph@christophdorn.com>",
8 9
     "repositories": [
9 10
         {
10 11
             "type": "git",
@@ -24,10 +25,15 @@
24 25
             "url": "http://www.opensource.org/licenses/mit-license.php"
25 26
         }
26 27
     ],
  28
+    "bin": {
  29
+        "commonjs": "./pinf-loader.sh"
  30
+    },
  31
+    "main": "./pinf-loader.js",
27 32
     "directories": {
28 33
         "lib": "lib/pinf-loader-js"
29 34
     },
30 35
     "scripts": {
  36
+        "postinstall": "node ./scripts/postinstall.js",
31 37
         "export": {
32 38
             "location": "./",
33 39
             "module": "/scripts/export.js"
9  programs/publish-to-npm/rsync-exclude.txt
@@ -7,16 +7,9 @@ README.md
7 7
 Thumbs.db
8 8
 .build/
9 9
 *.local.*
  10
+.*.jsc
10 11
 
11  
-/bin/
12 12
 /demos/
13 13
 /docs/
14  
-/lib/pinf-loader-js/adapter/jetpack.js
15  
-/lib/pinf-loader-js/adapter/narwhal.js
16  
-/lib/pinf-loader-js/platform/jetpack/
17 14
 /tests/
18  
-/programs/
19 15
 /NOTES.md
20  
-/pinf-loader
21  
-/pinf-loader.js
22  
-/pinf-loader.sh
2  scripts/export.js
... ...
@@ -1,4 +1,6 @@
1 1
 
  2
+// NOTE: Called via `commonjs --script export ...`
  3
+
2 4
 exports.main = function(env)
3 5
 {
4 6
 
46  scripts/postinstall.js
... ...
@@ -0,0 +1,46 @@
  1
+
  2
+// NOTE: Called via `npm run-script postinstall ...`
  3
+
  4
+var SYS = require("sys"),
  5
+	PATH = require("path"),
  6
+	FS = require("fs");
  7
+
  8
+/**
  9
+ * Update the `../pinf-loader.sh` script to set an absolute `BASE_PATH`.
  10
+ * This is necessary as the dynamic base path detection does not work because
  11
+ * npm links the `commonjs` binary using a relative path.
  12
+ */
  13
+function main()
  14
+{
  15
+	try {
  16
+
  17
+		var basePath = process.cwd(),
  18
+			scriptPath = basePath + "/pinf-loader.sh",
  19
+			// TODO: Adjust this based on ENV var
  20
+			baseSourcePath = "/pinf/workspaces/github.com/pinf/loader-js";
  21
+
  22
+		// If loader source found on local system we use that instead
  23
+		// of the code shipped with the NPM package!
  24
+		if (PATH.existsSync(baseSourcePath))
  25
+		{
  26
+			basePath = baseSourcePath;
  27
+			SYS.print([
  28
+			  "-------",
  29
+			  " NOTE: Linked `commonjs` command to source at '" + basePath + "'!",
  30
+			  "-------"
  31
+			].join("\n") + "\n\n");
  32
+		}
  33
+
  34
+		var scriptContent = "" + FS.readFileSync(scriptPath);
  35
+
  36
+		scriptContent = scriptContent.replace(/(\nBASE_PATH=).*(\n)/, "$1\"" + basePath + "\"$2");
  37
+
  38
+		FS.writeFileSync(scriptPath, scriptContent);
  39
+
  40
+	} catch(e) {
  41
+		console.error("Fatal Error '" + e + "' updating `pinf-loader.sh` script!");
  42
+		process.exit(1);
  43
+	}
  44
+}
  45
+
  46
+main();

0 notes on commit 913949f

Please sign in to comment.
Something went wrong with that request. Please try again.