@gauntface/cli
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -1,6 +0,12 @@ | ||
const util = require('util'); | ||
const exec = util.promisify(require('child_process').exec); | ||
const spawn = require('child_process').spawn; | ||
const { program } = require('commander'); | ||
program | ||
run().catch((err) => { | ||
console.error(`☠️ An unexpected error occured.`); | ||
console.error(err); | ||
return process.exit(1); | ||
}) | ||
async function run() { | ||
program | ||
.version('0.0.1') | ||
@@ -10,12 +16,13 @@ .requiredOption('--directory <type>', 'Directory of the site to upload') | ||
program.parse(process.argv); | ||
program.parse(process.argv); | ||
const opts = program.opts(); | ||
const opts = program.opts(); | ||
const directory = opts.directory; | ||
const bucketName = opts['bucket_name']; | ||
const directory = opts.directory; | ||
const bucketName = opts['bucket_name']; | ||
logMetadata(directory, bucketName); | ||
logMetadata(directory, bucketName); | ||
publishToS3Bucket(directory, bucketName); | ||
await publishToS3Bucket(directory, bucketName); | ||
} | ||
@@ -72,3 +79,24 @@ function logMetadata(directory, bucketName) { | ||
console.log(`🤖 Running \`${cmd}\``); | ||
await exec(cmd); | ||
const cmdPieces = cmd.split(' '); | ||
return new Promise((resolve, reject) => { | ||
// Note: We use spawn here since exec has a max buffer size for stdout and stderr that | ||
// AWS blasts through | ||
const cmdProcess = spawn(cmdPieces[0], cmdPieces.splice(1)) | ||
cmdProcess.stdout.on('data', function (data) { | ||
console.log(`${data}`); | ||
}); | ||
cmdProcess.stderr.on('data', function (data) { | ||
console.error(`${data}`); | ||
}); | ||
cmdProcess.on('close', function (code) { | ||
if (code != 0) { | ||
reject(`Unexpected error code: ${code}`); | ||
return | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
} |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A CLI tool to help with repetitive tasks.", | ||
@@ -9,0 +9,0 @@ "main": "index.js", |
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
15256
90