Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

18f-pages-server

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

18f-pages-server - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

70

lib/site-builder.js

@@ -114,3 +114,4 @@ 'use strict';

new ComponentFactory(config, builderOpts, branch, logger)),
finishBuild;
finishBuild,
migrateLog;

@@ -129,5 +130,2 @@ logger.log(info.repository.full_name + ':',

// latest status.
var newLogPath = path.join(
builder.configHandler.buildDestination, 'build.log');
if (err) {

@@ -139,23 +137,59 @@ logger.error(err.message ? err.message : err);

}
logger.close(function() {
return err ? reject(err) : resolve();
});
});
};
fs.rename(buildLog, newLogPath, function(renameErr) {
var errMsg;
migrateLog = function(err) {
var newLogPath = path.join(
builder.configHandler.buildDestination, 'build.log');
if (renameErr) {
errMsg = 'Error moving build log: ' + renameErr;
console.error(errMsg);
if (!err) {
reject(errMsg);
}
}
logger.close(function() {
return err ? reject(err) : resolve();
});
return copyLog(buildLog, newLogPath)
.then(function() {
return removeLog(buildLog);
})
.catch(function(err) {
console.error('Error moving build log: ' + (err.message || err));
return Promise.reject(err);
})
.then(function() {
return err ? Promise.reject(err) : Promise.resolve();
});
});
};
return builder.build()
.then(finishBuild, finishBuild);
.then(finishBuild, finishBuild)
.then(migrateLog, migrateLog);
};
// In the Dockerized 18F/knowledge-sharing-toolkit environment, the git
// repositories live on one Docker volume (pages/repos), and the generated
// sites live on another (pages/sites). This server orignally used
// fs.rename(), which failed in this environment with the error:
//
// Error moving build log: Error: EXDEV: cross-device link not permitted,
// rename '/usr/local/18f/pages/repos/pages-internal.18f.gov/hub.log' ->
// '/usr/local/18f/pages/sites/pages-internal.18f.gov/hub/build.log'
//
// Copying and manually removing the original log resolves this issue.
function copyLog(sourceLog, targetLog) {
return new Promise(function(resolve, reject) {
var sourceStream = fs.createReadStream(sourceLog),
targetStream = fs.createWriteStream(targetLog);
sourceStream.on('error', reject);
targetStream.on('error', reject);
targetStream.on('close', resolve);
sourceStream.pipe(targetStream);
});
}
function removeLog(sourceLog) {
return new Promise(function(resolve, reject) {
fs.unlink(sourceLog, function(err) {
return err ? reject(err) : resolve();
});
});
}
SiteBuilder.makeBuilderListener = function(webhook, builderConfig) {

@@ -162,0 +196,0 @@ var org = builderConfig.githubOrg || config.githubOrg,

{
"name": "18f-pages-server",
"version": "0.3.2",
"version": "0.3.3",
"description": "Static website publishing server for 18F Pages",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc