Skip to content

Commit

Permalink
refactor: update deps and remove unnecessary ones (#966)
Browse files Browse the repository at this point in the history
* refactor: update deps and remove unnecessary ones

* fix: add retryDelay to `fs.rm`

* chore: update more dependencies
  • Loading branch information
anonrig authored Sep 8, 2023
1 parent aa3eaa1 commit bd92122
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 97 deletions.
2 changes: 0 additions & 2 deletions lib/bin/citgm-all.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'make-promises-safe';

import * as os from 'os';

import async from 'async';
Expand Down
2 changes: 0 additions & 2 deletions lib/bin/citgm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'make-promises-safe';

import rootCheck from 'root-check';
import uidnumber from 'uid-number';

Expand Down
5 changes: 1 addition & 4 deletions lib/citgm.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { createHash } from 'crypto';
import { EventEmitter } from 'events';
import { promisify } from 'util';

import npa from 'npm-package-arg';
import BufferList from 'bl';
import whichLib from 'which';

const which = promisify(whichLib);
import which from 'which';

import { grabModuleData } from './grab-module-data.js';
import { grabProject } from './grab-project.js';
Expand Down
3 changes: 1 addition & 2 deletions lib/package-manager/get-executable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { promisify } from 'util';
import { fileURLToPath } from 'url';

import npmWhichLib from 'npm-which';
import whichLib from 'which';
import which from 'which';

const npmWhich = promisify(
npmWhichLib(dirname(fileURLToPath(import.meta.url)))
);
const which = promisify(whichLib);

export function getExecutable(binaryName) {
if (binaryName === 'yarn') {
Expand Down
3 changes: 1 addition & 2 deletions lib/package-manager/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { promisify } from 'util';

import readPackageJson from 'read-package-json';
import stripAnsi from 'strip-ansi';
import whichLib from 'which';
import which from 'which';

const readPackage = promisify(readPackageJson);
const which = promisify(whichLib);

import { createOptions } from '../create-options.js';
import { spawn } from '../spawn.js';
Expand Down
11 changes: 6 additions & 5 deletions lib/temp-directory.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { promisify } from 'util';
import { join } from 'path';
import { promises as fs } from 'fs';
import { randomUUID } from 'crypto';

import rimrafLib from 'rimraf';
import osenv from 'osenv';

const rimraf = promisify(rimrafLib);

export async function create(context) {
if (context.options && context.options.tmpDir) {
context.path = join(context.options.tmpDir, randomUUID());
Expand Down Expand Up @@ -38,7 +34,12 @@ export let remove = async function remove(context) {
`${context.module.name} rm.tempdir`,
context.path
);
await rimraf(context.path);
await fs.rm(context.path, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 10
});
};

// Used in tests to simulate errors in rimraf.
Expand Down
40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,39 @@
"license": "MIT",
"dependencies": {
"async": "^3.2.2",
"bl": "^5.0.0",
"chalk": "^5.0.0",
"columnify": "^1.5.4",
"execa": "^6.0.0",
"bl": "^6.0.7",
"chalk": "^5.3.0",
"columnify": "^1.6.0",
"execa": "^8.0.1",
"lodash": "^4.17.21",
"make-promises-safe": "^5.1.0",
"normalize-git-url": "^3.0.2",
"npm-package-arg": "^8.1.5",
"npm-package-arg": "^11.0.1",
"npm-which": "^3.0.1",
"osenv": "^0.1.5",
"read-package-json": "^4.1.1",
"rimraf": "^3.0.2",
"read-package-json": "^7.0.0",
"root-check": "^2.0.0",
"semver": "^7.3.5",
"semver": "^7.5.4",
"strip-ansi": "^7.0.1",
"supports-color": "^9.2.1",
"tar": "^6.1.11",
"tar": "^6.2.0",
"uid-number": "0.0.6",
"undici": "^5.5.1",
"which": "^2.0.2",
"winston": "^3.3.3",
"which": "^4.0.0",
"winston": "^3.10.0",
"xml-sanitizer": "^1.1.11",
"xmlbuilder": "^15.1.1",
"yargs": "^17.3.0",
"yarn": "^1.22.17"
"yarn": "^1.22.19"
},
"devDependencies": {
"ansi-regex": "^6.0.1",
"c8": "^7.10.0",
"eslint": "^8.4.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"fs-extra": "^10.0.0",
"prettier": "^2.5.1",
"c8": "^8.0.1",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3",
"string-to-stream": "^3.0.1",
"tap": "^16.2.0",
"tap": "^16.3.8",
"tap-parser": "^11.0.1",
"xml2js": "^0.5.0"
},
Expand All @@ -89,5 +86,6 @@
},
"engines": {
"node": "16.x || 18.x || 20.x"
}
},
"packageManager": "yarn@3.6.3"
}
17 changes: 9 additions & 8 deletions test/npm/test-npm-install.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { tmpdir } from 'os';
import { join, dirname } from 'path';
import { promisify } from 'util';
import { fileURLToPath } from 'url';
import { promises as fs } from 'fs';

import fse from 'fs-extra';
import tap from 'tap';
import rimrafLib from 'rimraf';

import { getPackageManagers } from '../../lib/package-manager/index.js';
import packageManagerInstall from '../../lib/package-manager/install.js';
import { npmContext } from '../helpers/make-context.js';

const { test } = tap;
const rimraf = promisify(rimrafLib);
const __dirname = dirname(fileURLToPath(import.meta.url));

const sandbox = join(tmpdir(), `citgm-${Date.now()}`);
Expand All @@ -31,9 +27,9 @@ test('npm-install: setup', async () => {
packageManagers = await getPackageManagers();
await fs.mkdir(sandbox, { recursive: true });
await Promise.all([
fse.copy(moduleFixtures, moduleTemp),
fse.copy(extraParamFixtures, extraParamTemp),
fse.copy(badFixtures, badTemp)
fs.cp(moduleFixtures, moduleTemp, { recursive: true }),
fs.cp(extraParamFixtures, extraParamTemp, { recursive: true }),
fs.cp(badFixtures, badTemp, { recursive: true })
]);
});

Expand Down Expand Up @@ -107,5 +103,10 @@ test('npm-install: failed install', async (t) => {
});

test('npm-install: teardown', async () => {
await rimraf(sandbox);
await fs.rm(sandbox, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 10
});
});
23 changes: 12 additions & 11 deletions test/npm/test-npm-test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { tmpdir } from 'os';
import { join, resolve, dirname } from 'path';
import { promisify } from 'util';
import { fileURLToPath } from 'url';
import { existsSync, promises as fs } from 'fs';

import fse from 'fs-extra';
import tap from 'tap';
import rimrafLib from 'rimraf';

import { npmContext } from '../helpers/make-context.js';
import { getPackageManagers } from '../../lib/package-manager/index.js';
import { test as packageManagerTest } from '../../lib/package-manager/test.js';

const { test } = tap;
const rimraf = promisify(rimrafLib);
const __dirname = dirname(fileURLToPath(import.meta.url));

const sandbox = join(tmpdir(), `citgm-${Date.now()}`);
Expand Down Expand Up @@ -43,12 +39,12 @@ test('npm-test: setup', async () => {
packageManagers = await getPackageManagers();
await fs.mkdir(sandbox, { recursive: true });
await Promise.all([
fse.copy(passFixtures, passTemp),
fse.copy(failFixtures, failTemp),
fse.copy(badFixtures, badTemp),
fse.copy(noTestScriptFixtures, noTestScriptTemp),
fse.copy(scriptsFixtures, scriptsTemp),
fse.copy(writeTmpdirFixtures, writeTmpdirTemp)
fs.cp(passFixtures, passTemp, { recursive: true }),
fs.cp(failFixtures, failTemp, { recursive: true }),
fs.cp(badFixtures, badTemp, { recursive: true }),
fs.cp(noTestScriptFixtures, noTestScriptTemp, { recursive: true }),
fs.cp(scriptsFixtures, scriptsTemp, { recursive: true }),
fs.cp(writeTmpdirFixtures, writeTmpdirTemp, { recursive: true })
]);
});

Expand Down Expand Up @@ -189,5 +185,10 @@ test('npm-test: tmpdir is redirected', async (t) => {
});

test('npm-test: teardown', async () => {
await rimraf(sandbox);
await fs.rm(sandbox, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 10
});
});
9 changes: 6 additions & 3 deletions test/reporter/test-reporter-junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { fileURLToPath } from 'url';
import { promisify } from 'util';

import tap from 'tap';
import rimrafLib from 'rimraf';
import _ from 'lodash';
import xml2js from 'xml2js';

import junitReporter from '../../lib/reporter/junit.js';

const { test } = tap;
const rimraf = promisify(rimrafLib);
const parseString = promisify(xml2js.parseString);

const fixtures = JSON.parse(
Expand Down Expand Up @@ -156,5 +154,10 @@ test('reporter.junit(): append to disk', (t) => {
});

test('reporter.junit(): teardown', async () => {
await rimraf(sandbox);
await fs.rm(sandbox, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 10
});
});
10 changes: 6 additions & 4 deletions test/reporter/test-reporter-tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { readFileSync, writeFileSync, promises as fs } from 'fs';
import { join, dirname } from 'path';
import { tmpdir } from 'os';
import { fileURLToPath } from 'url';
import { promisify } from 'util';

import tap from 'tap';
import rimrafLib from 'rimraf';
import Parser from 'tap-parser';
import str from 'string-to-stream';

Expand All @@ -18,7 +16,6 @@ const fixtures = JSON.parse(
);

const { test } = tap;
const rimraf = promisify(rimrafLib);

const fixturesPath = join(
dirname(fileURLToPath(import.meta.url)),
Expand Down Expand Up @@ -132,5 +129,10 @@ test('reporter.tap(): append to disk when file does not exist', (t) => {
});

test('reporter.tap(): teardown', async () => {
await rimraf(sandbox);
await fs.rm(sandbox, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 10
});
});
4 changes: 1 addition & 3 deletions test/test-citgm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import tap from 'tap';
import { test } from 'tap';

import { Tester } from '../lib/citgm.js';

const { test } = tap;

test('citgm: omg-i-pass', (t) => {
t.plan(2);
const options = {
Expand Down
10 changes: 6 additions & 4 deletions test/test-grab-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { tmpdir } from 'os';
import { promisify } from 'util';
import { promises as fs } from 'fs';

import tap from 'tap';
import rimrafLib from 'rimraf';

import { grabProject } from '../lib/grab-project.js';

const { test } = tap;
const rimraf = promisify(rimrafLib);

const __dirname = dirname(fileURLToPath(import.meta.url));
const sandbox = join(tmpdir(), `citgm-${Date.now()}`);
Expand Down Expand Up @@ -173,5 +170,10 @@ test('grab-project: timeout', async (t) => {
});

test('grab-project: teardown', async () => {
await rimraf(sandbox);
await fs.rm(sandbox, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 10
});
});
9 changes: 5 additions & 4 deletions test/test-temp-directory.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { promisify } from 'util';
import { promises as fs } from 'fs';

import tap from 'tap';
import rimrafLib from 'rimraf';

import * as tempDirectory from '../lib/temp-directory.js';

const { test } = tap;
const rimraf = promisify(rimrafLib);

const isWin32 = process.platform === 'win32';
const nullDevice = isWin32 ? '\\\\.\\NUL' : '/dev/null';
Expand Down Expand Up @@ -49,7 +46,11 @@ test('tempDirectory.create --tmpDir:', async (t) => {
);
const stats = await fs.stat(contextTmpDir.path);
t.ok(stats.isDirectory(), 'the path should exist and be a folder');
await rimraf('./.thisisatest');
await fs.rm('./.thisisatest', {
recursive: true,
force: true,
maxRetries: 10
});
});

test('tempDirectory.remove:', async (t) => {
Expand Down
Loading

0 comments on commit bd92122

Please sign in to comment.