Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ after_success:
- if [ -n "$TRAVIS_TAG" ]; then
npm install -g node-pre-gyp
npm install -g aws-sdk
node lifecycleScripts/clean
node-pre-gyp package
node-pre-gyp publish
fi
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test_script:
on_success:
- IF %APPVEYOR_REPO_TAG%==true npm install -g node-pre-gyp
- IF %APPVEYOR_REPO_TAG%==true npm install -g aws-sdk
- IF %APPVEYOR_REPO_TAG%==true node lifecycleScripts\clean
- IF %APPVEYOR_REPO_TAG%==true node-pre-gyp package
- IF %APPVEYOR_REPO_TAG%==true node-pre-gyp publish

Expand Down
143 changes: 3 additions & 140 deletions lifecycleScripts/clean.js
Original file line number Diff line number Diff line change
@@ -1,142 +1,5 @@
var fse = require("fs-extra");
var cleanForPublish = require("clean-for-publish");
var path = require("path");
var npm = require("npm");
var Promise = require("nodegit-promise");

var rooted = path.join.bind(path, __dirname, "..");
if (fse.existsSync(rooted(".didntcomefromthenpmregistry"))) {
console.error("[nodegit] We only clean when downloaded from the npm " +
"registry. Skipping clean.");
return;
}

npm.load({
"production": true
}, function() {

var filesToDelete = [
"build/Makefile",
"build/binding.Makefile",
"build/config.gypi",
"build/gyp-mac-tool",
"build/nodegit.target.mk",
"build/vendor",

"build/Release/.deps",
"build/Release/git2.a",
"build/Release/http_parser.a",
"build/Release/linker.lock",
"build/Release/obj.target",
"build/Release/openssl.a",
"build/Release/ssh2.a",
"build/Release/zlib.a",

"build/Debug/.deps",
"build/Debug/git2.a",
"build/Debug/http_parser.a",
"build/Debug/linker.lock",
"build/Debug/obj.target",
"build/Debug/openssl.a",
"build/Debug/ssh2.a",
"build/Debug/zlib.a",

"example",
"generate",
"include",
"lifecycleScripts",
"src",
"test",
"vendor",

".astylerc",
".editorconfig",
".gitingore",
".gitmodules",
".jshintrc",
".npmignore",
".travis.yml",
"appveyor.yml",
"binding.gyp",
"TESTING.md"
];

var modulesToPrune = [
"for-node-webkit",
"which-native-nodish",
"fs-extra",
"node-pre-gyp",
"npm"
];

console.info("[nodegit] Cleaning up after ourselves.");

Promise.all([
cleanFiles(),
pruneDevDependencies(),
pruneOtherDependencies()
]).then(
function success() {
console.info("[nodegit] Done cleaning, enjoy!");
},
function failure() {
console.error("[nodegit] Couldn't finish cleaning.");
}
);

function cleanFiles() {
console.info("[nodegit] Deleting unneeded files.");
return new Promise(function(resolve, reject) {
var failures = filesToDelete.some(function(deletable) {
try {
fse.removeSync(rooted(deletable));
return false;
}
catch (e) {
console.info("[nodegit] Error deleting files. Errored on " +
rooted(deletable) + ".");
console.error(e);

reject(e);
return true;
}
});

if (!failures) {
console.info("[nodegit] Finished deleting files.");
resolve();
}
});
}

function pruneDevDependencies() {
console.info("[nodegit] Pruning devdependencies.");
return new Promise(function (resolve, reject) {
npm.commands.prune(function(err) {
if (err) {
console.error("[nodegit] Failed pruning devdependencies.");
reject(err);
}
else {
console.info("[nodegit] Successfully pruned devdependencies.");
resolve();
}
});
});
}

function pruneOtherDependencies() {
console.info("[nodegit] Cleaning unneeded dependencies.");
return new Promise(function (resolve, reject) {
npm.commands.uninstall(modulesToPrune, function(err) {
if (err) {
console.error("[nodegit] Failed cleaning unneeded dependencies.");
reject(err);
}
else {
console.info("[nodegit] Successfully cleaned unneeded dependencies.");
resolve();
}
});
});
}
});
var location = path.join(__dirname, "..");
cleanForPublish(location);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"which-native-nodish": "^1.1.3"
},
"devDependencies": {
"clean-for-publish": "^1.0.2",
"combyne": "^0.8.1",
"coveralls": "^2.11.4",
"istanbul": "^0.3.20",
Expand Down