Skip to content

Commit

Permalink
refactor: replace globby with tinyglobby
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev authored Oct 14, 2024
1 parent 18ed3cf commit 2c966f1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ use of `package.json` configuration.

### Scripts

`scripts` is a [glob](https://github.com/sindresorhus/globby)
`scripts` is a [glob](https://github.com/SuperchupuDev/tinyglobby)
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/sindresorhus/globby)
`assets` is a [glob](https://github.com/SuperchupuDev/tinyglobby)
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,11 +2,11 @@

import assert from 'assert';
import fs from 'fs-extra';
import globby from 'globby';
import path from 'path';
import chalk from 'chalk';
import { minimatch } from 'minimatch';
import { builtinModules } from 'module';
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 globby.sync(ps, { dot: true });
return globSync(ps, { dot: true });
}

function expandFiles(efs: string | string[], base: string) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"@yao-pkg/pkg-fetch": "3.5.13",
"chalk": "^4.1.2",
"fs-extra": "^9.1.0",
"globby": "^11.1.0",
"into-stream": "^6.0.0",
"minimatch": "9.0.4",
"minimist": "^1.2.6",
"multistream": "^4.1.0",
"prebuild-install": "7.1.1",
"resolve": "^1.22.0",
"stream-meter": "^1.0.4"
"stream-meter": "^1.0.4",
"tinyglobby": "^0.2.9"
},
"devDependencies": {
"@babel/core": "7.23.0",
Expand Down
13 changes: 7 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
'use strict';

const chalk = require('chalk');
const globby = require('globby');
const path = require('path');
const { globSync } = require('tinyglobby');
const utils = require('./utils.js');
const host = 'node' + process.version.match(/^v(\d+)/)[1];
let target = process.argv[2] || 'host';
Expand Down Expand Up @@ -47,6 +47,7 @@ function joinAndForward(d) {
}

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

if (flavor.match(/^test/)) {
list.push(joinAndForward(`${flavor}/main.js`));
Expand All @@ -55,14 +56,14 @@ if (flavor.match(/^test/)) {
} else {
list.push(joinAndForward('**/main.js'));
if (flavor === 'no-npm') {
list.push('!' + joinAndForward('test-42-fetch-all'));
list.push('!' + joinAndForward('test-46-multi-arch'));
list.push('!' + joinAndForward('test-46-multi-arch-2'));
list.push('!' + joinAndForward('test-79-npm'));
ignore.push(joinAndForward('test-42-fetch-all'));
ignore.push(joinAndForward('test-46-multi-arch'));
ignore.push(joinAndForward('test-46-multi-arch-2'));
ignore.push(joinAndForward('test-79-npm'));
}
}

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

files.sort().some(function (file) {
file = path.resolve(file);
Expand Down
9 changes: 4 additions & 5 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const assert = require('assert');
const path = require('path');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
const globby = require('globby');
const { execSync } = require('child_process');
const { spawnSync } = require('child_process');
const { globSync } = require('tinyglobby');
const { execSync, spawnSync } = require('child_process');
const { existsSync, statSync, copyFileSync, readdirSync } = require('fs');
const stableStringify = require('json-stable-stringify');

Expand Down Expand Up @@ -157,11 +156,11 @@ module.exports.filesBefore = function (n) {
for (const ni of n) {
module.exports.vacuum.sync(ni);
}
return globby.sync('**/*', { nodir: true }).sort();
return globSync('**/*').sort();
};

module.exports.filesAfter = function (b, n) {
const a = globby.sync('**/*', { nodir: true }).sort();
const a = globSync('**/*').sort();
for (const bi of b) {
if (a.indexOf(bi) < 0) {
assert(false, `${bi} disappeared!?`);
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,11 @@ fastq@^1.6.0:
dependencies:
reusify "^1.0.4"

fdir@^6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.0.tgz#8e80ab4b18a2ac24beebf9d20d71e1bc2627dbae"
integrity sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ==

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 @@ -3756,6 +3761,11 @@ picomatch@^2.3.1:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

picomatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab"
integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==

please-upgrade-node@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942"
Expand Down Expand Up @@ -4516,6 +4526,14 @@ 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.9"
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.9.tgz#6baddd1b0fe416403efb0dd40442c7d7c03c1c66"
integrity sha512-8or1+BGEdk1Zkkw2ii16qSS7uVrQJPre5A9o/XkWPATkk23FZh/15BKFxPnlTy6vkljZxLqYCzzBMj30ZrSvjw==
dependencies:
fdir "^6.4.0"
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 2c966f1

Please sign in to comment.