Skip to content

Commit

Permalink
Split mkCleanDir and buildCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Sep 24, 2015
1 parent b093a45 commit 7411111
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 10 additions & 8 deletions lib/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ function popd() {
return run('popd');
}

function build(command, dir) {
function mkCleanDir(dir) {
return sequence([
run.bind(null, 'rm', '-rf', dir),
run.bind(null, 'mkdir', '-p', dir)
]);
}

function build(command) {
tracker._track('npm', 'run-script');
var commands = [];
if(dir) {
commands.push(run.bind(null, 'rm', '-rf', dir));
commands.push(run.bind(null, 'mkdir', '-p', dir));
}
commands.push(run.bind(null, command));
return command ? sequence(commands) : noop.then(function() {
return command ? run(command) : noop.then(function() {
log.verbose('No build command was provided.');
});
}
Expand Down Expand Up @@ -127,6 +128,7 @@ module.exports = {
run: run,
pushd: pushd,
popd: popd,
mkCleanDir: mkCleanDir,
build: build,
npmPublish: npmPublish,
copy: copy,
Expand Down
9 changes: 6 additions & 3 deletions lib/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function releaseSourceRepo(options) {
repo.isRepo,
repo.checkClean,
repo.bump,
repo.build,
repo.mkCleanDir,
repo.buildCommand,
repo.stage,
repo.stageDir,
repo.hasChanges
Expand Down Expand Up @@ -151,7 +152,6 @@ function releaseDistRepo(options) {
function getGenericTasks(options) {
return {
isRepo: git.isGitRepo,
build: shell.build.bind(null, options.buildCommand, options.dist.baseDir),
status: git.status,
stageDir: git.stageDir,
commit: git.commit.bind(null, '.', options.commitMessage, options.version),
Expand All @@ -164,10 +164,13 @@ function getGenericTasks(options) {

function getSrcRepoTasks(options) {

var isStageBuildDir = !!options.buildCommand && !options.dist.repo && options.dist.baseDir,
var isMakeBaseDir = options.buildCommand && options.dist.repo && options.dist.baseDir,
isStageBuildDir = !!options.buildCommand && !options.dist.repo && options.dist.baseDir,
isPublish = !options['non-interactive'] || (options.npm.publish && !options.dist.repo);

return _.extend({}, getGenericTasks(options), {
mkCleanDir: isMakeBaseDir ? shell.mkCleanDir.bind(null, options.dist.baseDir) : noop,
buildCommand: shell.build.bind(null, options.buildCommand),
checkClean: git.isWorkingDirClean.bind(null, options.requireCleanWorkingDir),
bump: shell.bump.bind(null, options.pkgFiles, options.version),
stage: git.stage.bind(null, options.pkgFiles),
Expand Down

0 comments on commit 7411111

Please sign in to comment.