Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: drop cpy dependency in favor of native node:fs functionality #944

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 0 additions & 81 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"devDependencies": {
"ava": "6.1.3",
"c8": "10.1.2",
"cpy": "11.1.0",
"cz-conventional-changelog": "3.3.0",
"fetch-mock": "npm:@gr2m/[email protected]",
"lockfile-lint": "4.14.0",
Expand Down
41 changes: 20 additions & 21 deletions test/glob-assets.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { resolve } from "node:path";
import { mkdir } from "node:fs/promises";
import { cp, mkdir } from "node:fs/promises";

import test from "ava";
import { isPlainObject, sortBy } from "lodash-es";
import { temporaryDirectory } from "tempy";
import cpy from "cpy";

import globAssets from "../lib/glob-assets.js";

Expand All @@ -15,15 +14,15 @@ const fixtures = "test/fixtures/files";

test("Retrieve file from single path", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, ["upload.txt"]);

t.deepEqual(globbedAssets, ["upload.txt"]);
});

test("Retrieve multiple files from path", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
"upload.txt",
"upload_other.txt",
Expand All @@ -37,7 +36,7 @@ test("Retrieve multiple files from path", async (t) => {

test("Include missing files as defined, using Object definition", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
"upload.txt",
{ path: "miss*.txt", label: "Missing" },
Expand All @@ -51,7 +50,7 @@ test("Include missing files as defined, using Object definition", async (t) => {

test("Retrieve multiple files from Object", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
{ path: "upload.txt", name: "upload_name", label: "Upload label" },
"upload_other.txt",
Expand All @@ -68,7 +67,7 @@ test("Retrieve multiple files from Object", async (t) => {

test("Retrieve multiple files without duplicates", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
"upload_other.txt",
"upload.txt",
Expand All @@ -86,7 +85,7 @@ test("Retrieve multiple files without duplicates", async (t) => {

test("Favor Object over String values when removing duplicates", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
"upload_other.txt",
"upload.txt",
Expand All @@ -108,15 +107,15 @@ test("Favor Object over String values when removing duplicates", async (t) => {

test("Retrieve file from single glob", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, ["upload.*"]);

t.deepEqual(globbedAssets, ["upload.txt"]);
});

test("Retrieve multiple files from single glob", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, ["*.txt"]);

t.deepEqual(
Expand All @@ -127,7 +126,7 @@ test("Retrieve multiple files from single glob", async (t) => {

test("Accept glob array with one value", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
["*load.txt"],
["*_other.txt"],
Expand All @@ -141,7 +140,7 @@ test("Accept glob array with one value", async (t) => {

test("Include globs that resolve to no files as defined", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
["upload.txt", "!upload.txt"],
]);
Expand All @@ -154,7 +153,7 @@ test("Include globs that resolve to no files as defined", async (t) => {

test("Accept glob array with one value for missing files", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
["*missing.txt"],
["*_other.txt"],
Expand All @@ -168,7 +167,7 @@ test("Accept glob array with one value for missing files", async (t) => {

test("Replace name by filename for Object that match multiple files", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
{ path: "*.txt", name: "upload_name", label: "Upload label" },
]);
Expand All @@ -188,31 +187,31 @@ test("Replace name by filename for Object that match multiple files", async (t)

test("Include dotfiles", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [".dot*"]);

t.deepEqual(globbedAssets, [".dotfile"]);
});

test("Ingnore single negated glob", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, ["!*.txt"]);

t.deepEqual(globbedAssets, []);
});

test("Ingnore single negated glob in Object", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [{ path: "!*.txt" }]);

t.deepEqual(globbedAssets, []);
});

test("Accept negated globs", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
["*.txt", "!**/*_other.txt"],
]);
Expand All @@ -222,7 +221,7 @@ test("Accept negated globs", async (t) => {

test("Expand directories", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, resolve(cwd, "dir"), { dot: true });
await cp(fixtures, resolve(cwd, "dir"), { recursive: true });
const globbedAssets = await globAssets({ cwd }, [["dir"]]);

t.deepEqual(
Expand All @@ -238,7 +237,7 @@ test("Expand directories", async (t) => {

test("Include empty temporaryDirectory as defined", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
await mkdir(resolve(cwd, "empty"), { recursive: true });
const globbedAssets = await globAssets({ cwd }, [["empty"]]);

Expand All @@ -247,7 +246,7 @@ test("Include empty temporaryDirectory as defined", async (t) => {

test("Deduplicate resulting files path", async (t) => {
const cwd = temporaryDirectory();
await cpy(fixtures, cwd, { dot: true });
await cp(fixtures, cwd, { recursive: true });
const globbedAssets = await globAssets({ cwd }, [
"./upload.txt",
resolve(cwd, "upload.txt"),
Expand Down