Skip to content

Commit 83e55e2

Browse files
committed
Merge pull request nodegit#1016 from cbargren/babel
Add babel to let the library use ES6
2 parents 50bb365 + 71bac25 commit 83e55e2

File tree

8 files changed

+68
-25
lines changed

8 files changed

+68
-25
lines changed

.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
/node_modules/
21
/build/
3-
/test/coverage/
4-
/test/repos/
5-
/test/test/
6-
/test/home/
7-
/src/
2+
/coverage/
3+
/dist/
84
/include/
95
/lib/enums.js
106
/lib/nodegit.js
11-
/coverage/
7+
/node_modules/
8+
/src/
9+
/test/coverage/
10+
/test/home/
11+
/test/repos/
12+
/test/test/
1213

1314
/generate/output
1415
/generate/**/*.json

.jshintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"boss": true,
33
"curly": true,
44
"eqnull": true,
5+
"esnext": true,
56
"evil": true,
67
"futurehostile": true,
78
"globals": {

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/build/
22
/example/
33
/examples/
4+
/lib/
45
/test/
56
/vendor/Release/
67

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ matrix:
4040
install:
4141
- ps: Install-Product node $env:nodejs_version $env:platform
4242
- ps: Start-Process c:\projects\nodegit\vendor\pageant.exe c:\projects\nodegit\vendor\private.ppk
43+
- npm install -g npm
4344
- cmd: npm install -g node-gyp
4445
- npm install
4546

lib/repository.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,7 @@ Repository.prototype.deleteTagByName = function(name) {
428428
* @return {RevWalk}
429429
*/
430430
Repository.prototype.createRevWalk = function() {
431-
var revWalk = Revwalk.create(this);
432-
revWalk.repo = this;
433-
return revWalk;
431+
return Revwalk.create(this);
434432
};
435433

436434
/**

lifecycleScripts/install.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var fromRegistry;
99
try {
1010
fs.statSync(path.join(__dirname, "..", "include"));
1111
fs.statSync(path.join(__dirname, "..", "src"));
12+
fs.statSync(path.join(__dirname, "..", "dist"));
1213
fromRegistry = true;
1314
}
1415
catch(e) {
@@ -60,9 +61,46 @@ function prepareAndBuild() {
6061
return prepareForBuild()
6162
.then(function() {
6263
return build();
64+
})
65+
.then(function() {
66+
return transpileJavascript();
6367
});
6468
}
6569

70+
function transpileJavascript() {
71+
var cmd = pathForTool("babel");
72+
var args = [
73+
"--presets",
74+
"es2015",
75+
"-d",
76+
"./dist",
77+
"./lib"
78+
];
79+
var opts = {
80+
cwd: ".",
81+
maxBuffer: Number.MAX_VALUE,
82+
env: process.env,
83+
stdio: "inherit"
84+
};
85+
var home = process.platform == "win32" ?
86+
process.env.USERPROFILE : process.env.HOME;
87+
88+
opts.env.HOME = path.join(home, ".nodegit-gyp");
89+
90+
return new Promise(function(resolve, reject) {
91+
var child = cp.spawn(cmd, args, opts);
92+
child.on("close", function(code) {
93+
if (code) {
94+
reject(code);
95+
process.exitCode = 13;
96+
}
97+
else {
98+
resolve();
99+
}
100+
});
101+
});
102+
}
103+
66104
function build() {
67105
console.info("[nodegit] Everything is ready to go, attempting compilation");
68106

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"email": "[email protected]"
2222
}
2323
],
24-
"main": "lib/nodegit.js",
24+
"main": "dist/nodegit.js",
2525
"repository": {
2626
"type": "git",
2727
"url": "git://github.com/nodegit/nodegit.git"
@@ -42,6 +42,8 @@
4242
"promisify-node": "~0.3.0"
4343
},
4444
"devDependencies": {
45+
"babel-cli": "^6.7.7",
46+
"babel-preset-es2015": "^6.6.0",
4547
"clean-for-publish": "~1.0.2",
4648
"combyne": "~0.8.1",
4749
"coveralls": "~2.11.4",
@@ -68,26 +70,27 @@
6870
"host": "https://nodegit.s3.amazonaws.com/nodegit/nodegit/"
6971
},
7072
"scripts": {
71-
"lint": "jshint lib test/tests test/utils examples lifecycleScripts",
73+
"babel": "babel --presets es2015 -d ./dist ./lib",
74+
"cov": "npm run cppcov && npm run filtercov && npm run mergecov",
7275
"coveralls": "cat ./test/coverage/merged.lcov | coveralls",
73-
"filtercov": "./lcov-1.10/bin/lcov --extract test/coverage/cpp/lcov_full.info $(pwd)/src/* $(pwd)/src/**/* $(pwd)/include/* $(pwd)/include/**/* --output-file test/coverage/cpp/lcov.info && rm test/coverage/cpp/lcov_full.info",
7476
"cppcov": "mkdir -p test/coverage/cpp && ./lcov-1.10/bin/lcov --gcov-tool /usr/bin/gcov-4.9 --capture --directory build/Release/obj.target/nodegit/src --output-file test/coverage/cpp/lcov_full.info",
75-
"mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && ./lcov-1.10/bin/genhtml test/coverage/merged.lcov --output-directory test/coverage/report",
76-
"cov": "npm run cppcov && npm run filtercov && npm run mergecov",
77-
"mocha": "mocha test/runner test/tests --timeout 15000",
78-
"mochaDebug": "mocha --debug-brk test/runner test/tests --timeout 15000",
79-
"test": "npm run lint && node --expose-gc test",
77+
"filtercov": "./lcov-1.10/bin/lcov --extract test/coverage/cpp/lcov_full.info $(pwd)/src/* $(pwd)/src/**/* $(pwd)/include/* $(pwd)/include/**/* --output-file test/coverage/cpp/lcov.info && rm test/coverage/cpp/lcov_full.info",
8078
"generateJson": "node generate/scripts/generateJson",
81-
"generateNativeCode": "node generate/scripts/generateNativeCode",
8279
"generateMissingTests": "node generate/scripts/generateMissingTests",
83-
"prepublish": "node lifecycleScripts/prepareForBuild.js",
80+
"generateNativeCode": "node generate/scripts/generateNativeCode",
8481
"install": "node lifecycleScripts/install",
8582
"installDebug": "BUILD_DEBUG=true npm install",
83+
"lint": "jshint lib test/tests test/utils examples lifecycleScripts",
84+
"mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && ./lcov-1.10/bin/genhtml test/coverage/merged.lcov --output-directory test/coverage/report",
85+
"mocha": "mocha test/runner test/tests --timeout 15000",
86+
"mochaDebug": "mocha --debug-brk test/runner test/tests --timeout 15000",
87+
"postinstall": "node postinstall.js",
88+
"prepublish": "node lifecycleScripts/prepareForBuild.js && npm run babel",
89+
"rebuild": "node generate && npm run babel && node-gyp configure build",
90+
"rebuildDebug": "node generate && npm run babel && node-gyp configure --debug build",
8691
"recompile": "node-gyp configure build",
87-
"rebuild": "node generate && node-gyp configure build",
8892
"recompileDebug": "node-gyp configure --debug build",
89-
"rebuildDebug": "node generate && node-gyp configure --debug build",
90-
"xcodeDebug": "node-gyp configure -- -f xcode",
91-
"postinstall": "node postinstall.js"
93+
"test": "npm run lint && node --expose-gc test",
94+
"xcodeDebug": "node-gyp configure -- -f xcode"
9295
}
9396
}

postinstall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (process.platform !== "linux") {
77
return;
88
}
99

10-
child_process.exec("node lib/nodegit.js", function(error, stdout, stderr) {
10+
child_process.exec("node dist/nodegit.js", function(error, stdout, stderr) {
1111
if (stderr && ~stderr.indexOf("libstdc++")) {
1212
console.log("[ERROR] Seems like the latest libstdc++ is missing on your system!");
1313
console.log("");

0 commit comments

Comments
 (0)