Skip to content

Commit

Permalink
Drop fs-extra & graceful-fs devDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mgol committed Nov 15, 2023
1 parent 091279a commit 412337a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 71 deletions.
43 changes: 0 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
"bluebird": "3.7.2",
"eslint": "8.53.0",
"eslint-config-mgol": "0.0.48",
"fs-extra": "11.1.1",
"graceful-fs": "4.2.11",
"husky": "8.0.3",
"lint-staged": "15.1.0",
"mocha": "10.2.0",
Expand Down
72 changes: 46 additions & 26 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

process.env.NO_COLOR = '1';

const assert = require('node:assert');
const { existsSync, readFileSync, readdirSync } = require('node:fs');
const fs = require('node:fs/promises');
const spawn = require('node:child_process').spawn;

const Promise = require('bluebird');
const semver = require('semver');
const assert = require('assert');
const sinon = require('sinon');
const spawn = require('child_process').spawn;

const realFs = require('fs');
const gracefulFs = require('graceful-fs');
gracefulFs.gracefulify(realFs);
const fs = require('fs-extra');
const timeout = 60000;

describe('checkDependencies', () => {
Expand Down Expand Up @@ -538,7 +537,7 @@ describe('checkDependencies', () => {
const fixtureDir = `${fixturePrefix}${fixtureName}`;
const fixtureCopyDir = `${fixtureDir}-copy`;
const depVersion = JSON.parse(
fs.readFileSync(
readFileSync(
`${fixturePrefix}${fixtureName}/${depsDirName}/jquery/${depsJsonName}`,
),
).version;
Expand All @@ -553,13 +552,17 @@ describe('checkDependencies', () => {
// sub-directory. We'll use it to check if the `install` command was invoked
// when technically not needed as we require it now always when pruning.
assert.strictEqual(
fs.existsSync(`${fixtureCopyDir}/${depsDirName}/jquery/dist`),
existsSync(`${fixtureCopyDir}/${depsDirName}/jquery/dist`),
false,
);

Promise.all([])
.then(() => fs.remove(fixtureCopyDir))
.then(() => fs.copy(fixtureDir, fixtureCopyDir))
Promise.resolve()
.then(() =>
fs.rm(fixtureCopyDir, { recursive: true, force: true }),
)
.then(() =>
fs.cp(fixtureDir, fixtureCopyDir, { recursive: true }),
)
.then(() => {
checkDeps(
{
Expand All @@ -570,7 +573,7 @@ describe('checkDependencies', () => {
output => {
// See the comment at the analogous assertion above.
assert.strictEqual(
fs.existsSync(
existsSync(
`${fixtureCopyDir}/${depsDirName}/jquery/dist`,
),
true,
Expand All @@ -595,7 +598,7 @@ describe('checkDependencies', () => {
);

const newDepVersion = JSON.parse(
fs.readFileSync(
readFileSync(
`${fixtureCopyDir}/${depsDirName}/jquery/${depsJsonName}`,
),
).version;
Expand All @@ -608,7 +611,10 @@ describe('checkDependencies', () => {
assert.strictEqual(output.status, 0);

// Clean up
fs.remove(fixtureCopyDir).then(done);
fs.rm(fixtureCopyDir, {
recursive: true,
force: true,
}).then(done);
},
);
});
Expand All @@ -622,13 +628,15 @@ describe('checkDependencies', () => {
const fixtureCopyDir = `${fixtureDir}-copy`;
const packageDir = `${fixturePrefix}${fixtureName}-copy`;

Promise.all([])
.then(() => fs.remove(fixtureCopyDir))
.then(() => fs.copy(fixtureDir, fixtureCopyDir))
Promise.resolve()
.then(() =>
fs.rm(fixtureCopyDir, { recursive: true, force: true }),
)
.then(() =>
fs.cp(fixtureDir, fixtureCopyDir, { recursive: true }),
)
.then(() => {
const depList = fs.readdirSync(
`${packageDir}/${depsDirName}`,
);
const depList = readdirSync(`${packageDir}/${depsDirName}`);
assert.deepEqual(
depList,
['jquery', 'json3'],
Expand All @@ -651,9 +659,9 @@ describe('checkDependencies', () => {
"Package json3 installed, though it shouldn't be",
]);

const depList = fs
.readdirSync(`${packageDir}/${depsDirName}`)
.filter(name => name[0] !== '.');
const depList = readdirSync(
`${packageDir}/${depsDirName}`,
).filter(name => name[0] !== '.');
assert.deepEqual(
depList,
['jquery'],
Expand All @@ -666,7 +674,12 @@ describe('checkDependencies', () => {
assert.strictEqual(output.status, 0);

// Clean up
return fs.remove(fixtureCopyDir).then(() => done());
return fs
.rm(fixtureCopyDir, {
recursive: true,
force: true,
})
.then(() => done());
},
);
});
Expand Down Expand Up @@ -868,7 +881,11 @@ describe('checkDependencies', () => {
const packageDir = `${fixturesRoot}/not-ok-install-copy`;

Promise.resolve()
.then(() => fs.copy(sourceForPackageDir, packageDir))
.then(() =>
fs.cp(sourceForPackageDir, packageDir, {
recursive: true,
}),
)
.then(() => {
const child = spawn(
process.execPath,
Expand Down Expand Up @@ -925,7 +942,10 @@ describe('checkDependencies', () => {
assert.strictEqual(code, 0);

// Clean up
fs.remove(packageDir).then(() => done());
fs.rm(packageDir, {
recursive: true,
force: true,
}).then(() => done());
});
});
});
Expand Down

0 comments on commit 412337a

Please sign in to comment.