Skip to content

Commit 63476a4

Browse files
authored
chore(deps): Update some dependencies, add Node 20 to CI (#116)
1 parent 4d5820d commit 63476a4

File tree

6 files changed

+1882
-6485
lines changed

6 files changed

+1882
-6485
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ jobs:
2525
runs-on: ${{ matrix.os }}
2626
strategy:
2727
matrix:
28-
node-version: [16.x, 18.x]
28+
node-version: [16.x, 18.x, 20.x]
2929
os: [ubuntu-latest, windows-latest, macos-latest]
3030

3131
steps:
32-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
3333

3434
- name: Use Node.js ${{ matrix.node-version }}
35-
uses: actions/setup-node@v3
35+
uses: actions/setup-node@v4
3636
with:
3737
node-version: ${{ matrix.node-version }}
3838

index.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@
1616
*/
1717

1818
const execa = require('execa');
19-
const pify = require('pify');
2019
const which = require('which');
21-
const path = require('path');
22-
const fs = require('fs-extra');
20+
const path = require('node:path');
21+
const fs = require('node:fs/promises');
2322
const { CordovaError, events } = require('cordova-common');
2423
const npa = require('npm-package-arg');
2524
const pacote = require('pacote');
2625
const semver = require('semver');
2726

28-
// pify's multiArgs unfortunately causes resolve to wrap errors in an Array.
29-
// Thus we wrap the function again to unpack these wrapped errors.
30-
const rslv = pify(require('resolve'), { multiArgs: true });
31-
const resolve = (...args) => rslv(...args).catch(([err]) => { throw err; });
27+
function resolvePackage (...args) {
28+
return new Promise((resolve, reject) => {
29+
require('resolve')(...args, (err, ...result) => {
30+
if (err) {
31+
reject(err);
32+
} else {
33+
resolve(result);
34+
}
35+
});
36+
});
37+
}
3238

3339
/**
3440
* Installs a module from npm, a git url or the local file system.
@@ -47,7 +53,7 @@ module.exports = async function (target, dest, opts = {}) {
4753
}
4854

4955
// Create dest if it doesn't exist yet
50-
fs.ensureDirSync(dest);
56+
await fs.mkdir(dest, { recursive: true });
5157

5258
// First try to determine the name from the spec using npa. This is very cheap.
5359
let { name, rawSpec } = npa(target, dest);
@@ -83,7 +89,7 @@ async function installPackage (target, dest, opts) {
8389
await isNpmInstalled();
8490

8591
// Ensure that `npm` installs to `dest` and not any of its ancestors
86-
await fs.ensureDir(path.join(dest, 'node_modules'));
92+
await fs.mkdir(path.join(dest, 'node_modules'), { recursive: true });
8793

8894
// Run `npm` to install requested package
8995
const args = npmArgs(target, opts);
@@ -114,7 +120,7 @@ async function resolvePathToPackage (name, basedir) {
114120

115121
// We resolve the path to the module's package.json to avoid getting the
116122
// path to `main` which could be located anywhere in the package
117-
const [pkgJsonPath, pkgJson] = await resolve(`${name}/package.json`, { paths, basedir });
123+
const [pkgJsonPath, pkgJson] = await resolvePackage(`${name}/package.json`, { paths, basedir });
118124

119125
return [path.dirname(pkgJsonPath), pkgJson];
120126
}

0 commit comments

Comments
 (0)