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 dependencies and drop Node.js < 18 support #129

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: CI
on:
push:
branches:
- "**"
- "!dependabot/**"
- "main"
pull_request:
workflow_dispatch:

Expand All @@ -23,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [14, 16, 18, 20]
node: [18, 20]

steps:
- name: Clone repository
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ on:
push:
branches:
- main
- "!dependabot/**"
pull_request:
branches:
- main
- "!dependabot/**"
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: Lint
on:
push:
branches:
- "**"
- "!dependabot/**"
- "main"
pull_request:
workflow_dispatch:

env:
FORCE_COLOR: 2
NODE: 18
NODE: 20

permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

const program = require('commander');
const { program } = require('commander');
const cabinet = require('../index.js');
const { name, description, version } = require('../package.json');

Expand Down
40 changes: 19 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ module.exports = function(options = {}) {

if (!resolver) {
debug('using generic resolver');
if (!resolveDependencyPath) {
resolveDependencyPath = require('resolve-dependency-path');
}
resolveDependencyPath ||= require('resolve-dependency-path');

resolver = resolveDependencyPath;
}
Expand Down Expand Up @@ -114,9 +112,7 @@ module.exports.unregister = function(extension) {
* @return {String}
*/
module.exports._getJSType = function(options = {}) {
if (!getModuleType) {
getModuleType = require('module-definition');
}
getModuleType ||= require('module-definition');

if (options.config) {
return 'amd';
Expand All @@ -136,9 +132,7 @@ module.exports._getJSType = function(options = {}) {
};

function getCompilerOptionsFromTsConfig(tsConfig) {
if (!ts) {
ts = require('typescript');
}
ts ||= require('typescript');

debug(`given typescript config: ${tsConfig}`);
let compilerOptions = {};
Expand Down Expand Up @@ -195,9 +189,7 @@ function jsLookup(options) {
switch (type) {
case 'amd': {
debug('using amd resolver');
if (!amdLookup) {
amdLookup = require('module-lookup-amd');
}
amdLookup ||= require('module-lookup-amd');

return amdLookup({
config,
Expand All @@ -217,7 +209,12 @@ function jsLookup(options) {

case 'webpack': {
debug('using webpack resolver for es6');
return resolveWebpackPath({ dependency, filename, directory, webpackConfig });
return resolveWebpackPath({
dependency,
filename,
directory,
webpackConfig
});
}

default: {
Expand All @@ -230,12 +227,17 @@ function tsLookup({ dependency, filename, directory, webpackConfig, tsConfig, ts
debug('performing a typescript lookup');

if (typeof tsConfig === 'string') {
tsConfigPath = tsConfigPath || path.dirname(tsConfig);
tsConfigPath ||= path.dirname(tsConfig);
}

if (!tsConfig && webpackConfig) {
debug('using webpack resolver for typescript');
return resolveWebpackPath({ dependency, filename, directory, webpackConfig });
return resolveWebpackPath({
dependency,
filename,
directory,
webpackConfig
});
}

const compilerOptions = getCompilerOptionsFromTsConfig(tsConfig);
Expand Down Expand Up @@ -328,9 +330,7 @@ function commonJSLookup(options) {
const { filename, directory, nodeModulesConfig, tsConfig } = options;
let { dependency } = options;

if (!resolve) {
resolve = require('resolve');
}
resolve ||= require('resolve');

if (!dependency) {
debug('blank dependency given. Returning early.');
Expand Down Expand Up @@ -422,9 +422,7 @@ function vueLookup(options) {
}

function resolveWebpackPath({ dependency, filename, directory, webpackConfig }) {
if (!webpackResolve) {
webpackResolve = require('enhanced-resolve');
}
webpackResolve ||= require('enhanced-resolve');

webpackConfig = path.resolve(webpackConfig);
let loadedConfig;
Expand Down
Loading