From a5a2a311d0ce631260ae61134cf89b501f977670 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 14 May 2021 10:54:23 -0700 Subject: [PATCH 1/6] chore: move files into "/src" dir --- index.d.ts => src/index.d.ts | 0 index.js => src/index.js | 0 sync.d.ts => src/sync.d.ts | 0 sync.js => src/sync.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename index.d.ts => src/index.d.ts (100%) rename index.js => src/index.js (100%) rename sync.d.ts => src/sync.d.ts (100%) rename sync.js => src/sync.js (100%) diff --git a/index.d.ts b/src/index.d.ts similarity index 100% rename from index.d.ts rename to src/index.d.ts diff --git a/index.js b/src/index.js similarity index 100% rename from index.js rename to src/index.js diff --git a/sync.d.ts b/src/sync.d.ts similarity index 100% rename from sync.d.ts rename to src/sync.d.ts diff --git a/sync.js b/src/sync.js similarity index 100% rename from sync.js rename to src/sync.js From 4b58d2ed9b978a67fefc354c60f93fad3c82363a Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 14 May 2021 10:59:17 -0700 Subject: [PATCH 2/6] chore: setup `bundt` builder --- .gitignore | 3 +++ package.json | 13 +++++++++++-- src/index.js | 15 ++++++++------- src/sync.js | 13 +++++++------ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index a734e5b..b2c4b31 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ node_modules .DS_Store *.lock *.log + +/dist +/sync diff --git a/package.json b/package.json index 30ee39e..594fcc8 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "0.2.8", "description": "Tiny and extremely fast globbing", "repository": "terkelg/tiny-glob", + "module": "dist/index.mjs", + "main": "dist/index.js", "types": "index.d.ts", "license": "MIT", "author": { @@ -11,10 +13,12 @@ "url": "https://terkel.com" }, "files": [ - "*.js", - "*.d.ts" + "*.d.ts", + "dist", + "sync" ], "scripts": { + "build": "bundt", "bench": "node bench", "test": "tape test/*.js | tap-spec" }, @@ -23,9 +27,14 @@ "globrex": "^0.1.2" }, "devDependencies": { + "bundt": "1.1.2", "tap-spec": "^5.0.0", "tape": "^5.0.1" }, + "modes": { + "sync": "src/sync.js", + "default": "src/index.js" + }, "keywords": [ "glob", "globbing", diff --git a/src/index.js b/src/index.js index b57c2ad..df61fce 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,9 @@ -const fs = require('fs'); -const globrex = require('globrex'); -const { promisify } = require('util'); -const globalyzer = require('globalyzer'); -const { join, resolve, relative } = require('path'); +import * as fs from 'fs'; +import globrex from 'globrex'; +import { promisify } from 'util'; +import globalyzer from 'globalyzer'; +import { join, resolve, relative } from 'path'; + const isHidden = /(^|[\\\/])\.[^\\\/\.]/g; const readdir = promisify(fs.readdir); const stat = promisify(fs.stat); @@ -50,7 +51,7 @@ async function walk(output, prefix, lexer, opts, dirname='', level=0) { * @param {Boolean} [options.flush=false] Reset cache object * @returns {Array} array containing matching files */ -module.exports = async function (str, opts={}) { +export default async function (str, opts={}) { if (!str) return []; let glob = globalyzer(str); @@ -80,4 +81,4 @@ module.exports = async function (str, opts={}) { await walk(matches, glob.base, path, opts, '.', 0); return opts.absolute ? matches.map(x => resolve(opts.cwd, x)) : matches; -}; +} diff --git a/src/sync.js b/src/sync.js index d2080df..3c138ee 100644 --- a/src/sync.js +++ b/src/sync.js @@ -1,7 +1,8 @@ -const fs = require('fs'); -const globrex = require('globrex'); -const globalyzer = require('globalyzer'); -const { join, resolve, relative } = require('path'); +import * as fs from 'fs'; +import globrex from 'globrex'; +import globalyzer from 'globalyzer'; +import { join, resolve, relative } from 'path'; + const isHidden = /(^|[\\\/])\.[^\\\/\.]/g; let CACHE = {}; @@ -48,7 +49,7 @@ function walk(output, prefix, lexer, opts, dirname='', level=0) { * @param {Boolean} [options.flush=false] Reset cache object * @returns {Array} array containing matching files */ -module.exports = function (str, opts={}) { +export default function (str, opts={}) { if (!str) return []; let glob = globalyzer(str); @@ -78,4 +79,4 @@ module.exports = function (str, opts={}) { walk(matches, glob.base, path, opts, '.', 0); return opts.absolute ? matches.map(x => resolve(opts.cwd, x)) : matches; -}; +} From ce61a6d7ba3d711128bfeddc156d26c74d84a5e5 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 14 May 2021 11:06:22 -0700 Subject: [PATCH 3/6] feat: define "exports" mapping --- package.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package.json b/package.json index 594fcc8..8811154 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,17 @@ "dist", "sync" ], + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./sync": { + "import": "./sync/index.mjs", + "require": "./sync/index.js" + }, + "./package.json": "./package.json" + }, "scripts": { "build": "bundt", "bench": "node bench", From 6f2f1d273fae015f6226bc6e79285ca6dfbcd908 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 14 May 2021 11:08:51 -0700 Subject: [PATCH 4/6] chore: add `pretest` script (temporary) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8811154..306cb3d 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "scripts": { "build": "bundt", "bench": "node bench", + "pretest": "npm run build", "test": "tape test/*.js | tap-spec" }, "dependencies": { From 81d00fa37f2b2e3e9cc9fc81cd03114c84f40353 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 14 May 2021 11:10:19 -0700 Subject: [PATCH 5/6] chore: update test require --- test/glob.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/glob.js b/test/glob.js index c19e6f9..0779477 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,7 +1,7 @@ const test = require('tape'); const { join, resolve } = require('path'); const { order, unixify } = require('./helpers'); -const glob = require('../'); +const glob = require('../dist'); const cwd = join(__dirname, 'fixtures'); From ca9ba51b070bac4706791bacd1282fe9b55c591a Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 14 May 2021 11:13:01 -0700 Subject: [PATCH 6/6] chore: include `bundt` changes to pkg-lock --- .gitignore | 1 + package-lock.json | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/.gitignore b/.gitignore index b2c4b31..2b587fa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules /dist /sync +/index.d.ts diff --git a/package-lock.json b/package-lock.json index da25efe..94cd6ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,12 +47,30 @@ "concat-map": "0.0.1" } }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, "buffer-shims": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "dev": true }, + "bundt": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/bundt/-/bundt-1.1.2.tgz", + "integrity": "sha512-q6hkfd1v7/Xcfnblt82zGzX16+RaNJC9qATtmszMbhrJDbrir/UjxTJUCcNAXWw9JVEpoQPAB70IYpDfCXjRsg==", + "dev": true, + "requires": { + "kleur": "^4.0.0", + "mk-dirs": "^3.0.0", + "rewrite-imports": "^2.0.0", + "terser": "^4.8.0" + } + }, "call-bind": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.0.tgz", @@ -76,6 +94,12 @@ "supports-color": "^2.0.0" } }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -465,6 +489,12 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, + "kleur": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", + "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", + "dev": true + }, "lodash": { "version": "4.17.20", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", @@ -486,6 +516,12 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, + "mk-dirs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mk-dirs/-/mk-dirs-3.0.0.tgz", + "integrity": "sha512-FEZDdUFb88hgdnsfAPa4VxcPVOd+8GyZ2jsI965im5bjBlBYhrvXuTqLka/UHa6YdUNN/kZBsVgofhZ3322AJw==", + "dev": true + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -653,6 +689,12 @@ "through": "~2.3.4" } }, + "rewrite-imports": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/rewrite-imports/-/rewrite-imports-2.0.3.tgz", + "integrity": "sha512-R7ICJEeP3y+d/q4C8YEJj9nRP0JyiSqG07uc0oQh8JvAe706dDFVL95GBZYCjADqmhArZWWjfM/5EcmVu4/B+g==", + "dev": true + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -669,6 +711,22 @@ "object-inspect": "^1.8.0" } }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "split": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/split/-/split-1.0.0.tgz", @@ -785,6 +843,17 @@ "through": "^2.3.8" } }, + "terser": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", + "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + } + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",