Skip to content

chore(deps): Update some dependencies, add Node 20 to CI #116

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

Merged
merged 1 commit into from
Apr 15, 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
26 changes: 16 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,25 @@
*/

const execa = require('execa');
const pify = require('pify');
const which = require('which');
const path = require('path');
const fs = require('fs-extra');
const path = require('node:path');
const fs = require('node:fs/promises');
const { CordovaError, events } = require('cordova-common');
const npa = require('npm-package-arg');
const pacote = require('pacote');
const semver = require('semver');

// pify's multiArgs unfortunately causes resolve to wrap errors in an Array.
// Thus we wrap the function again to unpack these wrapped errors.
const rslv = pify(require('resolve'), { multiArgs: true });
const resolve = (...args) => rslv(...args).catch(([err]) => { throw err; });
function resolvePackage (...args) {
return new Promise((resolve, reject) => {
require('resolve')(...args, (err, ...result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
}

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

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

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

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

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

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

return [path.dirname(pkgJsonPath), pkgJson];
}
Expand Down
Loading
Loading