Skip to content

Commit

Permalink
Update dependencies and drop Node.js < 18 support (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Apr 10, 2024
1 parent f8ae7e2 commit 10e9c2d
Show file tree
Hide file tree
Showing 8 changed files with 2,231 additions and 7,582 deletions.
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

0 comments on commit 10e9c2d

Please sign in to comment.