Skip to content

Commit

Permalink
fix: revert of "refactor: replace globby with tinyglobby (#103)"
Browse files Browse the repository at this point in the history
This reverts commit 99a2632.
  • Loading branch information
robertsLando committed Nov 6, 2024
1 parent 8913dff commit d4c704c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 56 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ use of `package.json` configuration.

### Scripts

`scripts` is a [glob](https://github.com/SuperchupuDev/tinyglobby)
`scripts` is a [glob](https://github.com/sindresorhus/globby)
or list of globs. Files specified as `scripts` will be compiled
using `v8::ScriptCompiler` and placed into executable without
sources. They must conform to the JS standards of those Node.js versions
you target (see [Targets](#targets)), i.e. be already transpiled.

### Assets

`assets` is a [glob](https://github.com/SuperchupuDev/tinyglobby)
`assets` is a [glob](https://github.com/sindresorhus/globby)
or list of globs. Files specified as `assets` will be packaged
into executable as raw content without modifications. Javascript
files may also be specified as `assets`. Their sources will
Expand Down
4 changes: 2 additions & 2 deletions lib/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import assert from 'assert';
import fs from 'fs/promises';
import globby from 'globby';
import path from 'path';
import { builtinModules } from 'module';
import picomatch from 'picomatch';
import { globSync } from 'tinyglobby';

import {
ALIAS_AS_RELATIVE,
Expand Down Expand Up @@ -194,7 +194,7 @@ function upon(p: string, base: string) {
}

function collect(ps: string[]) {
return globSync(ps, { absolute: true, dot: true });
return globby.sync(ps, { dot: true });
}

function expandFiles(efs: string | string[], base: string) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@babel/parser": "^7.23.0",
"@babel/types": "^7.23.0",
"@yao-pkg/pkg-fetch": "3.5.17",
"globby": "11.1.0",
"into-stream": "^6.0.0",
"minimist": "^1.2.6",
"multistream": "^4.1.0",
Expand All @@ -35,7 +36,6 @@
"resolve": "^1.22.0",
"stream-meter": "^1.0.4",
"tar": "^7.4.3",
"tinyglobby": "^0.2.9",
"unzipper": "^0.12.3"
},
"devDependencies": {
Expand Down
37 changes: 22 additions & 15 deletions test/test-79-npm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const UPM = process.env.USE_PREINSTALLED_MODULES || false; // USE_PREINSTALLED_M
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const { globSync } = require('tinyglobby');
const globby = require('globby');
const utils = require('../utils.js');

assert(!module.parent);
Expand Down Expand Up @@ -127,12 +127,19 @@ if (!UPM) {
})();

// note to developpers:
// you can set the env variable FILTER to something like "better-sqlite3/*.js"
// you can set the env variable FILTER to something like "better-sqlite3/*.js"
// to restrict this test to this single test case
const inputs = globSync([process.env.FILTER || '*/*.js'], {
absolute: true,
ignore: ['*/*.config.js', '*/*.meta.js', '*/gulpfile.js', '*/*fixture*'],
}).map((p) => path.normalize(p));
const inputs = globby
.sync([
process.env.FILTER || './*/*.js',
'!./*/*.config.js',
'!./*/*.meta.js',
'!./*/gulpfile.js',
'!./*/*fixture*',
])
.map(function (result) {
return path.resolve(result);
});

let times = {};
const ci = process.env.CI;
Expand Down Expand Up @@ -302,14 +309,14 @@ inputs.some(function (input) {
const deployFiles = [];

if (!meta.deployFiles && !meta.deployFilesFrom) {
globSync(path.join(foldy, 'node_modules', '**', '*.node')).some(
function (deployFrom) {
globby
.sync(path.join(foldy, 'node_modules', '**', '*.node'))
.some(function (deployFrom) {
deployFiles.push([
deployFrom,
path.join(path.dirname(output), path.basename(deployFrom)),
]);
},
);
});
}

const deployFilesRelative = [];
Expand Down Expand Up @@ -355,8 +362,9 @@ inputs.some(function (input) {
if (statFrom.isFile()) {
deployFiles.push([deployFrom, deployTo]);
} else {
globSync(path.join(deployFrom, '**', '*')).some(
function (deployFrom2) {
globby
.sync(path.join(deployFrom, '**', '*'))
.some(function (deployFrom2) {
const r = path.relative(deployFrom, deployFrom2);
const deployTo2 = path.join(deployTo, r);
if (fs.existsSync(deployFrom2)) {
Expand All @@ -365,8 +373,7 @@ inputs.some(function (input) {
deployFiles.push([deployFrom2, deployTo2]);
}
}
},
);
});
}
}
});
Expand Down Expand Up @@ -404,7 +411,7 @@ inputs.some(function (input) {
}
}

const rubbishes = globSync(path.join(path.dirname(output), '**', '*'));
const rubbishes = globby.sync(path.join(path.dirname(output), '**', '*'));

rubbishes.some(function (rubbish) {
utils.vacuum.sync(rubbish);
Expand Down
9 changes: 4 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

'use strict';

const globby = require('globby');
const path = require('path');
const pc = require('picocolors');
const { globSync } = require('tinyglobby');
const utils = require('./utils.js');
const { spawn } = require('child_process');
const host = 'node' + utils.getNodeMajorVersion();
Expand Down Expand Up @@ -53,7 +53,6 @@ function joinAndForward(d) {
}

const list = [];
const ignore = [];

// test that should be run on `host` target only
const npmTests = [
Expand All @@ -80,14 +79,14 @@ if (flavor.match(/^test/)) {
list.push(joinAndForward('**/main.js'));
if (flavor === 'no-npm') {
// TODO: fix this test
ignore.push(joinAndForward('test-79-npm'));
list.push('!' + joinAndForward('test-79-npm'));
npmTests.forEach((t) => {
ignore.push(joinAndForward(t));
list.push('!' + joinAndForward(t));
});
}
}

const files = globSync(list, { ignore });
const files = globby.sync(list);

function msToHumanDuration(ms) {
if (ms < 1000) return `${ms}ms`;
Expand Down
9 changes: 3 additions & 6 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const assert = require('assert');
const path = require('path');
const rimraf = require('rimraf');
const { globSync } = require('tinyglobby');
const globby = require('globby');
const { execSync, spawnSync } = require('child_process');
const {
existsSync,
Expand Down Expand Up @@ -194,7 +194,7 @@ module.exports.filesBefore = function (n) {
for (const ni of n) {
module.exports.vacuum.sync(ni);
}
return globSync('**/*').sort();
return globby.sync('**/*', { nodir: true }).sort();
};

/**
Expand All @@ -204,10 +204,7 @@ module.exports.filesBefore = function (n) {
* @param {string[]} newComers New files produced by test that should be removed
*/
module.exports.filesAfter = function (before, newComers) {
// actual files in the directory
const a = globSync('**/*').sort();

// check that all files in `b` exist, otherwise fail
const a = globby.sync('**/*', { nodir: true }).sort();
for (const bi of before) {
if (a.indexOf(bi) < 0) {
assert(false, `${bi} disappeared!?`);
Expand Down
37 changes: 12 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2137,11 +2137,6 @@ fastq@^1.6.0:
dependencies:
reusify "^1.0.4"

fdir@^6.4.2:
version "6.4.2"
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.2.tgz#ddaa7ce1831b161bc3657bb99cb36e1622702689"
integrity sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==

fetch-blob@^3.1.2, fetch-blob@^3.1.4:
version "3.2.0"
resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9"
Expand Down Expand Up @@ -2441,18 +2436,7 @@ globalthis@^1.0.3:
define-properties "^1.2.1"
gopd "^1.0.1"

globby@13.2.2:
version "13.2.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-13.2.2.tgz#63b90b1bf68619c2135475cbd4e71e66aa090592"
integrity sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==
dependencies:
dir-glob "^3.0.1"
fast-glob "^3.3.0"
ignore "^5.2.4"
merge2 "^1.4.1"
slash "^4.0.0"

globby@^11.1.0:
globby@11.1.0, globby@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
Expand All @@ -2464,6 +2448,17 @@ globby@^11.1.0:
merge2 "^1.4.1"
slash "^3.0.0"

globby@13.2.2:
version "13.2.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-13.2.2.tgz#63b90b1bf68619c2135475cbd4e71e66aa090592"
integrity sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==
dependencies:
dir-glob "^3.0.1"
fast-glob "^3.3.0"
ignore "^5.2.4"
merge2 "^1.4.1"
slash "^4.0.0"

gopd@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c"
Expand Down Expand Up @@ -4662,14 +4657,6 @@ text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==

tinyglobby@^0.2.9:
version "0.2.10"
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.10.tgz#e712cf2dc9b95a1f5c5bbd159720e15833977a0f"
integrity sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew==
dependencies:
fdir "^6.4.2"
picomatch "^4.0.2"

titleize@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/titleize/-/titleize-3.0.0.tgz#71c12eb7fdd2558aa8a44b0be83b8a76694acd53"
Expand Down

0 comments on commit d4c704c

Please sign in to comment.