69cbce9
commit 862dba8b7d040b688f21926eceb14a6bd185fbbe
69cbce9
Author: Tom Hughes <tom@compton.nu>
69cbce9
Date:   Sun Nov 8 11:33:04 2015 +0000
69cbce9
69cbce9
    Some fixes for Cakefile
69cbce9
    
69cbce9
    - follow FHS and Fedora Node.js packaging guidelines
69cbce9
    - support DESTDIR
69cbce9
    - preserve timestamps when installing
69cbce9
69cbce9
diff --git a/Cakefile b/Cakefile
69cbce9
index c9a675f..c361e64 100644
69cbce9
--- a/Cakefile
69cbce9
+++ b/Cakefile
69cbce9
@@ -95,20 +95,21 @@ releaseHeader = (date, version, prevVersion) -> """
T.C. Hollingsworth ed19ff3
 option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
T.C. Hollingsworth ed19ff3
 
T.C. Hollingsworth ed19ff3
 task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
T.C. Hollingsworth ed19ff3
+  destdir = options.destdir or ''
T.C. Hollingsworth ed19ff3
   base = options.prefix or '/usr/local'
T.C. Hollingsworth ed19ff3
-  lib  = "#{base}/lib/coffee-script"
T.C. Hollingsworth ed19ff3
+  lib  = "#{base}/share/coffee-script"
T.C. Hollingsworth ed19ff3
   bin  = "#{base}/bin"
T.C. Hollingsworth ed19ff3
-  node = "~/.node_libraries/coffee-script"
T.C. Hollingsworth ed19ff3
+  node = "#{base}/lib/node_modules/coffee-script"
T.C. Hollingsworth ed19ff3
   console.log   "Installing CoffeeScript to #{lib}"
T.C. Hollingsworth ed19ff3
   console.log   "Linking to #{node}"
T.C. Hollingsworth ed19ff3
   console.log   "Linking 'coffee' to #{bin}/coffee"
T.C. Hollingsworth ed19ff3
   exec([
T.C. Hollingsworth ed19ff3
-    "mkdir -p #{lib} #{bin}"
69cbce9
-    "cp -rf bin lib LICENSE README.md package.json src #{lib}"
T.C. Hollingsworth ed19ff3
-    "ln -sfn #{lib}/bin/coffee #{bin}/coffee"
T.C. Hollingsworth ed19ff3
-    "ln -sfn #{lib}/bin/cake #{bin}/cake"
T.C. Hollingsworth ed19ff3
-    "mkdir -p ~/.node_libraries"
T.C. Hollingsworth ed19ff3
-    "ln -sfn #{lib}/lib/coffee-script #{node}"
T.C. Hollingsworth ed19ff3
+    "mkdir -p #{destdir}/#{lib} #{destdir}/#{bin}"
T.C. Hollingsworth ed19ff3
+    "cp -prf bin extras lib package.json src #{destdir}/#{lib}"
T.C. Hollingsworth ed19ff3
+    "ln -sfn #{lib}/bin/coffee #{destdir}/#{bin}/coffee"
T.C. Hollingsworth ed19ff3
+    "ln -sfn #{lib}/bin/cake #{destdir}/#{bin}/cake"
T.C. Hollingsworth ed19ff3
+    "mkdir -p #{destdir}/#{node}"
T.C. Hollingsworth ed19ff3
+    "ln -sfn #{lib}/lib/coffee-script #{destdir}/#{node}"
T.C. Hollingsworth ed19ff3
   ].join(' && '), (err, stdout, stderr) ->
T.C. Hollingsworth ed19ff3
     if err then console.log stderr.trim() else log 'done', green
T.C. Hollingsworth ed19ff3
   )