18f-pages-server
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -21,5 +21,17 @@ 'use strict'; | ||
options = opts || {cwd: runner.sitePath}, | ||
msg = message || 'rebuild failed for'; | ||
msg = message || 'rebuild failed for', | ||
error; | ||
if (options.stdio) { | ||
runner.logger.error('CommandRunner ignoring stdio option value: ' | ||
+ options.stdio); | ||
delete options.stdio; | ||
} | ||
command = childProcess.spawn(path, args, options); | ||
command.on('error', function(err) { | ||
error = err; | ||
reject('Error: ' + msg + ' ' + runner.repoName + ' due to failed ' + | ||
'command: ' + path + ' ' + args.join(' ') + ': ' + err.message); | ||
}); | ||
@@ -37,2 +49,5 @@ command.stdout.setEncoding('utf8'); | ||
command.on('close', function(code) { | ||
if (error) { | ||
return; | ||
} | ||
if (code !== 0) { | ||
@@ -39,0 +54,0 @@ reject('Error: ' + msg + ' ' + runner.repoName + ' with exit code ' + |
@@ -53,3 +53,3 @@ 'use strict'; | ||
cloneArgs = ['clone', cloneAddr, '--branch', branch], | ||
cloneOpts = {cwd: gitRunner.repoDir, stdio: 'inherit'}, | ||
cloneOpts = { cwd: gitRunner.repoDir }, | ||
errMsg = 'failed to clone'; | ||
@@ -56,0 +56,0 @@ |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var path = require('path'); | ||
var mkdirp = require('mkdirp'); | ||
@@ -158,3 +159,6 @@ module.exports = SiteBuilder; | ||
}; | ||
return builder.build() | ||
return createBuildDestinationDir(builder.configHandler.buildDestination) | ||
.then(function() { | ||
return builder.build(); | ||
}) | ||
.then(finishBuild, finishBuild) | ||
@@ -164,2 +168,14 @@ .then(migrateLog, migrateLog); | ||
function createBuildDestinationDir(buildDestinationDir) { | ||
return new Promise(function(resolve, reject) { | ||
mkdirp(buildDestinationDir, function(err) { | ||
if (err) { | ||
return reject(new Error('Creating build destination dir failed: ' + | ||
err.message)); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
// In the Dockerized 18F/knowledge-sharing-toolkit environment, the git | ||
@@ -166,0 +182,0 @@ // repositories live on one Docker volume (pages/repos), and the generated |
{ | ||
"name": "18f-pages-server", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Static website publishing server for 18F Pages", | ||
@@ -44,8 +44,9 @@ "main": "index.js", | ||
"gulp-mocha": "^2.1.3", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.3.3", | ||
"mock-spawn": "^0.2.6", | ||
"sinon": "^1.17.0", | ||
"yargs": "^3.32.0", | ||
"temp": "^0.8.3" | ||
"temp": "^0.8.3", | ||
"yargs": "^3.32.0" | ||
} | ||
} |
@@ -442,3 +442,3 @@ # 18f-pages-server | ||
Feel free to [file an issue](https://github.com/18F/pages-server/issues) or to | ||
ping [@mbland](https://github.com/mbland) with any questions you may have, | ||
ping @ertzeid, @jbarnicle, or @mtorres253 with any questions you may have, | ||
especially if the current documentation should've addressed your needs, but | ||
@@ -445,0 +445,0 @@ didn't. |
'use strict'; | ||
var CommandRunner = require('../lib/command-runner'); | ||
var path = require('path'); | ||
var sinon = require('sinon'); | ||
@@ -8,3 +9,3 @@ var chai = require('chai'); | ||
var TEST_COMMAND = 'fake-command.js'; | ||
var TEST_COMMAND = path.join(__dirname, 'fake-command.js'); | ||
@@ -40,2 +41,21 @@ chai.should(); | ||
}); | ||
it('should log and ignore the stdio option', function() { | ||
return runner.run('node', [TEST_COMMAND, 'foobar'], { stdio: 'inherit' }) | ||
.should.be.fulfilled.then(function() { | ||
fakeLogger.log.args.should.eql([['foobar']]); | ||
fakeLogger.error.args.should.eql( | ||
[['CommandRunner ignoring stdio option value: inherit']]); | ||
}); | ||
}); | ||
it('should log a proper error if the command fails to spawn', function() { | ||
return runner.run('bogus-node', ['nonexistent', 'test']) | ||
.should.be.rejectedWith('Error: rebuild failed for pages-server due ' + | ||
'to failed command: bogus-node nonexistent test: ') | ||
.then(function() { | ||
sinon.assert.notCalled(fakeLogger.log); | ||
sinon.assert.notCalled(fakeLogger.error); | ||
}); | ||
}); | ||
}); |
@@ -91,3 +91,3 @@ 'use strict'; | ||
], | ||
{ cwd: opts.repoDir, stdio: 'inherit' }, | ||
{ cwd: opts.repoDir }, | ||
'failed to clone' | ||
@@ -94,0 +94,0 @@ ] |
@@ -250,5 +250,2 @@ 'use strict'; | ||
return filesHelper.createDir('dest_dir'); | ||
}) | ||
.then(function() { | ||
return filesHelper.createDir(path.join('dest_dir', 'foo')); | ||
}); | ||
@@ -309,2 +306,4 @@ }); | ||
// Ensure the output dir gets cleaned up. | ||
filesHelper.dirs.push(path.join('dest_dir', 'foo')); | ||
mySpawn.setDefault(mySpawn.simple(0)); | ||
@@ -338,2 +337,14 @@ captureLogs(); | ||
it('should build the site when the dest dir already exists', function() { | ||
var handler = SiteBuilder.makeBuilderListener(webhook, builderConfig); | ||
mySpawn.setDefault(mySpawn.simple(0)); | ||
captureLogs(); | ||
return filesHelper.createDir(path.join('dest_dir', 'foo')) | ||
.then(function() { | ||
return handler(incomingPayload).should.be.fulfilled; | ||
}) | ||
.then(restoreLogs, restoreLogs); | ||
}); | ||
it('should create a builder that fails to build the site', function() { | ||
@@ -345,2 +356,6 @@ var handler = SiteBuilder.makeBuilderListener(webhook, builderConfig), | ||
// Ensure the output dir gets cleaned up. Though cloning the repo will | ||
// fail, the builder will still create the output directory so that the | ||
// build.log file will still be accessible to diagnose the error. | ||
filesHelper.dirs.push(path.join('dest_dir', 'foo')); | ||
mySpawn.setDefault(mySpawn.simple(1)); | ||
@@ -347,0 +362,0 @@ captureLogs(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
133561
42
2399
12