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

Update remaining major dependencies #1114

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
26 changes: 17 additions & 9 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@

'use strict';

var camelCase = require('camel-case');
var camelCase = require('camel-case').camelCase;
var fs = require('fs');
var info = require('./package.json');
var minify = require('./' + info.main).minify;
var paramCase = require('param-case');
var paramCase = require('param-case').paramCase;
var path = require('path');
var program = require('commander');
var command = require('commander').Command;
var program = new command();
var programOptions = program.opts();

program._name = info.name;
program.version(info.version);
Expand All @@ -43,6 +45,12 @@ function fatal(message) {
process.exit(1);
}

// If no argument has been specified on the command line, show help message and exit
if (!process.argv.slice(2).length) {
program.outputHelp();
process.exit();
}

/**
* JSON does not support regexes, so, e.g., JSON.parse() will not create
* a RegExp from the JSON value `[ "/matchString/" ]`, which is
Expand Down Expand Up @@ -198,7 +206,7 @@ program.arguments('[files...]').action(function(files) {
function createOptions() {
var options = {};
mainOptionKeys.forEach(function(key) {
var param = program[key === 'minifyURLs' ? 'minifyUrls' : camelCase(key)];
var param = programOptions[key === 'minifyURLs' ? 'minifyUrls' : camelCase(key)];
if (typeof param !== 'undefined') {
options[key] = param;
}
Expand Down Expand Up @@ -280,14 +288,14 @@ function writeMinify() {
catch (e) {
fatal('Minification error:\n' + e.message);
}
(program.output ? fs.createWriteStream(program.output).on('error', function(e) {
fatal('Cannot write ' + program.output + '\n' + e.message);
(programOptions.output ? fs.createWriteStream(programOptions.output).on('error', function(e) {
fatal('Cannot write ' + programOptions.output + '\n' + e.message);
}) : process.stdout).write(minified);
}

var inputDir = program.inputDir;
var outputDir = program.outputDir;
var fileExt = program.fileExt;
var inputDir = programOptions.inputDir;
var outputDir = programOptions.outputDir;
var fileExt = programOptions.fileExt;
if (inputDir || outputDir) {
if (!inputDir) {
fatal('The option output-dir needs to be used with the option input-dir. If you are working with a single file, use -o.');
Expand Down
90 changes: 66 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
"test": "grunt test"
},
"dependencies": {
"camel-case": "^3.0.0",
"camel-case": "^4.1.2",
"clean-css": "^5.2.1",
"commander": "^2.20.3",
"commander": "^7.2.0",
"he": "^1.2.0",
"param-case": "^2.1.1",
"param-case": "^3.0.4",
"relateurl": "^0.2.7",
"uglify-js": "^3.14.2"
},
Expand Down