Apply babel for es6 on nodejs v0.10
authoryons.kim <yons.kim@samsung.com>
Fri, 13 Nov 2015 05:15:49 +0000 (14:15 +0900)
committerjh5.cho <jh5.cho@samsung.com>
Fri, 13 Nov 2015 05:30:28 +0000 (14:30 +0900)
Current apm's nodejs version is 0.10. Until now, this program uses
very higher nodejs's version(4.2.1). To lower this and not modify code,
add babel & preset for es6.

Change-Id: I6b51d700e43bcd4a4f5464782141b0870c88d54a

.gitignore [new file with mode: 0644]
jsn-cli/bin/jsn-cli
jsn-cli/lib/cli.js
jsn-cli/package.json [changed mode: 0755->0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..f278418
--- /dev/null
@@ -0,0 +1 @@
+jsn-cli/node_modules
index 6e383b5..79aacd7 100755 (executable)
@@ -1,4 +1,19 @@
-#!/usr/bin/env node
+#!/usr/bin/env nodejs
 
-const cli = require('../lib/cli');
-cli(process.argv);
+var fs = require('fs');
+var path = require('path');
+
+// get current path of execution
+var execPath = process.cwd();
+
+// get real path because it can be real bin file or symbolic link file
+var binDir = path.dirname(fs.realpathSync(process.argv[1]));
+
+// change cwd
+process.chdir(path.join(binDir, '..', 'lib'));
+
+// babel for es6
+require('babel-core/register');
+
+// compile & execute
+require('../lib/cli')(process.argv, execPath);
index 93196e1..57317f1 100755 (executable)
@@ -14,7 +14,7 @@ module.exports = cli;
   * Promises: http://www.html5rocks.com/en/tutorials/es6/promises/
   * q: https://github.com/kriskowal/q
   */
-function cli(inputArgv) {
+function cli(inputArgv, execPath) {
   // verify inputArgv
   const argv = getVerifiedArgv(inputArgv);
   if (argv === null) {
@@ -22,19 +22,11 @@ function cli(inputArgv) {
     return;
   }
 
-  // add exec path
-  const execPath = process.cwd();
   argv.exec_path_ = execPath;
 
   // setup manifest parser
   const parser = new (require('./parser'))(execPath);
 
-  // get real path because it can be real bin file or symbolic link file
-  const binDir = path.dirname(fs.realpathSync(process.argv[1]));
-
-  // change cwd
-  process.chdir(path.join(binDir, '..', 'lib'));
-
   // process command
   switch (argv.cmd_) {
     case 'create':
old mode 100755 (executable)
new mode 100644 (file)
index f218641..91a8b17
@@ -7,17 +7,35 @@
   "bin": {
     "jsn-cli": "./bin/jsn-cli"
   },
-  "engines": { "node": ">= 4.2.1" },
+  "engines": {
+    "node": ">= 0.10.25"
+  },
   "dependencies": {
-      "elementtree": "0.1.6",
-      "pretty-data": "0.40.0",
-      "q": "1.4.1",
-      "shelljs": "0.5.3",
-      "string-template": "0.2.1"
-    },
-  "author": { "name": "Yongseop Kim", "email": "yons.kim@samsung.com" },
+    "babel-core": "^6.1.19",
+    "babel-preset-es2015": "^6.1.18",
+    "elementtree": "0.1.6",
+    "pretty-data": "0.40.0",
+    "q": "1.4.1",
+    "shelljs": "0.5.3",
+    "string-template": "0.2.1"
+  },
+  "babel": {
+    "presets": [
+      "es2015"
+    ]
+  },
+  "author": {
+    "name": "Yongseop Kim",
+    "email": "yons.kim@samsung.com"
+  },
   "contributors": [
-    { "name": "Yongseop Kim", "email": "yons.kim@samsung.com" },
-    { "name": "Joonghyun Cho", "email": "jh5.cho@samsung.com" }
+    {
+      "name": "Yongseop Kim",
+      "email": "yons.kim@samsung.com"
+    },
+    {
+      "name": "Joonghyun Cho",
+      "email": "jh5.cho@samsung.com"
+    }
   ]
 }