Skip to content

Remove deprecated camel-case and param-case dependencies #186

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 5 additions & 6 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import fs from 'fs';
import path from 'path';
import { createRequire } from 'module';
import { camelCase } from 'camel-case';
import { paramCase } from 'param-case';
import { Command } from 'commander';
import { minify } from './src/htmlminifier.js';
import * as changeCase from 'change-case';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use named exports

This way we could profit from tree-shaking and introduce less diffs to this PR.

Suggested change
import * as changeCase from 'change-case';
import { camelCase, kebabCase } from 'change-case';

Don't forget to upgrade other usages :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, fixed.


const require = createRequire(import.meta.url);

Expand Down Expand Up @@ -146,13 +145,13 @@ const mainOptionKeys = Object.keys(mainOptions);
mainOptionKeys.forEach(function (key) {
const option = mainOptions[key];
if (Array.isArray(option)) {
key = key === 'minifyURLs' ? '--minify-urls' : '--' + paramCase(key);
key = key === 'minifyURLs' ? '--minify-urls' : '--' + changeCase.kebabCase(key);
key += option[1] === parseJSON ? ' [value]' : ' <value>';
program.option(key, option[0], option[1]);
} else if (~['html5', 'includeAutoGeneratedTags'].indexOf(key)) {
program.option('--no-' + paramCase(key), option);
program.option('--no-' + changeCase.kebabCase(key), option);
} else {
program.option('--' + paramCase(key), option);
program.option('--' + changeCase.kebabCase(key), option);
}
});
program.option('-o --output <file>', 'Specify output file (if not specified STDOUT will be used for output)');
Expand Down Expand Up @@ -202,7 +201,7 @@ function createOptions() {
const options = {};

mainOptionKeys.forEach(function (key) {
const param = programOptions[key === 'minifyURLs' ? 'minifyUrls' : camelCase(key)];
const param = programOptions[key === 'minifyURLs' ? 'minifyUrls' : changeCase.camelCase(key)];

if (typeof param !== 'undefined') {
options[key] = param;
Expand Down
65 changes: 9 additions & 56 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@
"prepare": "is-ci || husky install"
},
"dependencies": {
"camel-case": "^4.1.2",
"change-case": "^5.4.4",
"clean-css": "~5.3.2",
"commander": "^10.0.0",
"entities": "^4.4.0",
"param-case": "^3.0.4",
"relateurl": "^0.2.7",
"terser": "^5.15.1"
},
Expand Down