s3-npm-cache
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "s3-npm-cache", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Forget lengthy npm install processes in your build pipeline. This script allows your build pipeline to cache your node_modules in S3 if your package.json hasn't changed.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,32 +5,33 @@ /* | ||
// Libararies | ||
var md5 = require('md5-file'), | ||
helpers = require('./helpers.js'); | ||
// Arguments | ||
var s3BucketName = process.argv[3], | ||
packageJsonFileLocation = process.argv[2], | ||
packageJsonFile = packageJsonFileLocation + '/package.json', | ||
nodeModulesFolder = packageJsonFileLocation + '/node_modules', | ||
s3PackageName = md5.sync(packageJsonFile) + ".zip"; | ||
var init = function (s3BucketName, packageJsonFileLocation) { | ||
var packageJsonFile = packageJsonFileLocation + '/package.json', | ||
nodeModulesFolder = packageJsonFileLocation + '/node_modules', | ||
s3PackageName = md5.sync(packageJsonFile) + ".zip"; | ||
// Actions | ||
var unzipNodeModules = function (buffer) { | ||
console.log('Found ZIP file. Unzipping.'); | ||
helpers.unzip(buffer, nodeModulesFolder); | ||
}; | ||
var unzipNodeModules = function (buffer) { | ||
console.log('Found ZIP file. Unzipping.'); | ||
helpers.unzip(buffer, nodeModulesFolder); | ||
}; | ||
var uploadNewFile = function () { | ||
console.log(s3PackageName, 'not found or error occurred. Uploading new package...'); | ||
helpers.installNodeModules(packageJsonFileLocation); | ||
helpers.createZip(nodeModulesFolder, s3PackageName); | ||
helpers.uploadFileToS3(s3PackageName); | ||
var uploadNewFile = function () { | ||
console.log(s3PackageName, 'not found or error occurred. Uploading new package...'); | ||
helpers.installNodeModules(packageJsonFileLocation); | ||
helpers.createZip(nodeModulesFolder, s3PackageName); | ||
helpers.uploadFileToS3(s3PackageName); | ||
}; | ||
// Lift off! | ||
console.log('Attempting to retrieve ZIP file from S3 -', s3BucketName, '/', s3PackageName); | ||
helpers.setS3BucketName(s3BucketName); | ||
helpers.getFileFromS3(s3PackageName) | ||
.then(unzipNodeModules) | ||
.catch(uploadNewFile); | ||
}; | ||
// Lift off! | ||
console.log('Attempting to retrieve ZIP file from S3 -', s3BucketName, '/', s3PackageName); | ||
helpers.setS3BucketName(s3BucketName); | ||
helpers.getFileFromS3(s3PackageName) | ||
.then(unzipNodeModules) | ||
.catch(uploadNewFile); | ||
module.exports = { | ||
init: init | ||
}; |
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
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
4678
8