Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build failure do to output from prepublish scripts #30

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions index.js
Expand Up @@ -278,6 +278,15 @@ exports.build = function build(argv, callback) {
}

function doNpmPack(_, callback) {
var findPackPath = function(output) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prevailing style closures in this module is to use named function statements and to put them at the end of the parent function, not assigned anonymous function expressions.

In this case, however, it is not even a closure and it is only used once, so I think it might be better off to just inline the checks than to make them a function.

var outputLines = output.split('\n');

// the pack filename should be on the second to last line of the output.
if (outputLines.length > 1) {
return null; //outputLines[outputLines.length - 2];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always return null?

}
return null;
};
var ignoreFiles = shell.find('node_modules').filter(function(file) {
return file.match(/\.(git|npm)ignore$/);
});
Expand All @@ -286,8 +295,14 @@ exports.build = function build(argv, callback) {
runWait('npm --quiet pack', function(er, output) {
if (er) return callback(er);

// npm pack output is a single line with the pack file name
var src = output.split('\n')[0];
var src = findPackPath(output);

if (!src) {
var er = Error('Error finding path to packed archive');
console.log(er.message);
return callback(er);
}

var dst = path.join('..', src);

console.log('Running `mv -f %s %s`', src, dst);
Expand Down