From c6d6c12a20679a598a3f60b513e60bb296996a46 Mon Sep 17 00:00:00 2001 From: "yons.kim" Date: Fri, 13 Nov 2015 14:15:49 +0900 Subject: [PATCH] Apply babel for es6 on nodejs v0.10 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 | 1 + jsn-cli/bin/jsn-cli | 21 ++++++++++++++++++--- jsn-cli/lib/cli.js | 10 +--------- jsn-cli/package.json | 38 ++++++++++++++++++++++++++++---------- 4 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 .gitignore mode change 100755 => 100644 jsn-cli/package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f278418 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +jsn-cli/node_modules diff --git a/jsn-cli/bin/jsn-cli b/jsn-cli/bin/jsn-cli index 6e383b5..79aacd7 100755 --- a/jsn-cli/bin/jsn-cli +++ b/jsn-cli/bin/jsn-cli @@ -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); diff --git a/jsn-cli/lib/cli.js b/jsn-cli/lib/cli.js index 93196e1..57317f1 100755 --- a/jsn-cli/lib/cli.js +++ b/jsn-cli/lib/cli.js @@ -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': diff --git a/jsn-cli/package.json b/jsn-cli/package.json old mode 100755 new mode 100644 index f218641..91a8b17 --- a/jsn-cli/package.json +++ b/jsn-cli/package.json @@ -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" + } ] } -- 2.7.4