Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadiagaurang committed May 1, 2022
2 parents 6ece011 + 6556759 commit c5f477b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 61 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Options:
### Prod

```bash
npx minify-all-cli -s "/home/ubuntu/source" -d "/home/ubuntu/compressed" --skipFileExtensions=.mp3,.mp4 --logLevel=info
npx minify-all-cli -s "/home/ubuntu/source" -d "/home/ubuntu/compressed" --skipFileExtensions=.mp3 --skipFileExtensions=.mp4 --logLevel=warn
```

### Local

```bash
node . -s "/home/ubuntu/source" -d "/home/ubuntu/compressed" --skipFileExtensions=.mp3,.mp4 --logLevel=info
node . -s "/home/ubuntu/source" -d "/home/ubuntu/compressed" --skipFileExtensions=.mp3 --skipFileExtensions=.mp4 --logLevel=info
```

## License
Expand Down
8 changes: 4 additions & 4 deletions bin/minify-all-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const cliOptions = yargs
.option("c", { alias: "skipCSS", describe: "Should minify CSS the file or skip it?", type: "boolean", demandOption: false })
.option("h", { alias: "skipHTML", describe: "Should minify HTML the file or skip it?", type: "boolean", demandOption: false })
.option("g", { alias: "doGzip", describe: "Should gzip the file or skip it?", type: "boolean", demandOption: false })
.option("m", { alias: "skipFileMasks", describe: "Partial Filder Path to skip it over", type: "string", demandOption: false })
.option("m", { alias: "skipFileMasks", describe: "Partial Filder Path to skip minification", type: "array", demandOption: false })
.option("e", { alias: "skipFileExtensions", describe: "File Extensions to skip it over", type: "array", demandOption: false })
.option("i", { alias: "ignoreFileMasks", describe: "Partial Filder Path to ignore it over", type: "string", demandOption: false })
.option("i", { alias: "ignoreFileMasks", describe: "Partial Filder Path to ignore minification and copy to destination", type: "array", demandOption: false })
.option("f", { alias: "configFile", describe: "Specifies a json configuration file for the UglifyJS, CSSNano and HTML Minifier module", type: "string", demandOption: false })
.option("l", { alias: "logLevel", describe: "Set log level to print warn, log, error, fatal messages", type: "string", demandOption: false })
.option("p", { alias: "processCount", describe: "Specifies process count to set maximum degree of parallelism", type: "number", demandOption: false })
Expand All @@ -24,9 +24,9 @@ const cliOptions = yargs
skipCSS: cliOptions.skipCSS || cliOptions.c || false,
skipHTML: cliOptions.skipHTML || cliOptions.h || false,
doGzip: cliOptions.doGzip || cliOptions.g || false,
skipFileMasks: cliOptions.skipFileMasks || cliOptions.m || "",
skipFileMasks: cliOptions.skipFileMasks || cliOptions.m || [],
skipFileExtensions: cliOptions.skipFileExtensions || cliOptions.e || [],
ignoreFileMasks: cliOptions.ignoreFileMasks || cliOptions.i || "",
ignoreFileMasks: cliOptions.ignoreFileMasks || cliOptions.i || [],
configFile: cliOptions.configFile || cliOptions.f || null,
logLevel: cliOptions.logLevel || cliOptions.l || "info",
processCount: cliOptions.processCount || cliOptions.p || 10
Expand Down
12 changes: 10 additions & 2 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = class MinifyAllCLI {
skipCSS: false,
skipHTML: false,
doGzip: false,
skipFileMasks: "",
skipFileMasks: [],
skipFileExtensions: [".mp3", ".mp4"],
ignoreFileMasks: "",
ignoreFileMasks: [],
configFile: null,
logLevel: "info",
processCount: 10
Expand All @@ -39,11 +39,19 @@ module.exports = class MinifyAllCLI {
process() {
var me = this;

// Check Source Directory is Absolute; if not then convert to absolute
if(!path.isAbsolute(me.SourceDirectory)) {
me.SourceDirectory = path.resolve(me.SourceDirectory);
}
// Validate Source Directory
if (!fs.existsSync(me.SourceDirectory)) {
throw "SourceDirectory doesn't exists!";
}

// Check Destination Directory is Absolute; if not then convert to absolute
if(!path.isAbsolute(me.DestinationDirectory)) {
me.DestinationDirectory = path.resolve(me.DestinationDirectory);
}
// Validate Destination Directory and delete if already exists
if (fs.existsSync(me.DestinationDirectory)) {
fs.rmSync(me.DestinationDirectory, { recursive: true });
Expand Down
104 changes: 52 additions & 52 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minify-all-cli",
"version": "1.0.8",
"version": "1.0.9",
"description": "Minify All JS, CSS and HTML files in a folder by using UglifyJS, CSSNano and HTMLMinifier with an option to gzip all the files as well.",
"main": "bin/minify-all-cli.js",
"bin": {
Expand All @@ -22,6 +22,7 @@
"Minify All HTML",
"Compress",
"uglifyjs",
"",
"cssnano",
"html-minifier",
"gzip"
Expand Down

0 comments on commit c5f477b

Please sign in to comment.