Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help/usage statement. #5

Merged
merged 2 commits into from
Sep 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@

var fs = require("fs");

const FOLDER_PATH = (process.argv[2][0] == "./")?process.argv[2]:"./"+process.argv[2];
const MODULE_NAME = process.argv[3];
function printUsage(code) {
console.log(`Usage: ${__filename} [-h] <asset_folder> <output_file>`);
console.log(' asset_folder: The folder containing the source assets for the module being created.');
console.log(' output_file: The resulting javascript source file where the module will be written. This file can be required after running pre-require to load the source assets.');
process.exit(code || 0);
}

const args = process.argv.slice(2);

if (args.length === 1 && (args[0] === '-h')) {
printUsage();
}

if (args.length !== 2) {
console.log('Error: required command line arguments not provided.');
printUsage(1);
}

const FOLDER_PATH = (args[0][0] == "./")?args[0]:"./"+args[0];
const MODULE_NAME = args[1];


fs.readdir(FOLDER_PATH, function(err, items) {
Expand Down