From 8be40d3fbe08e8b82c94dcc079e97f015b738ebc Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Wed, 13 Dec 2023 00:21:41 -0800 Subject: [PATCH 01/12] fix getFirstExistingParentPath when called with root folder --- package-lock.json | 28 +++++++++++++++ package.json | 3 +- src/functions/getFirstExistingParentPath.ts | 12 ++++--- src/index.ts | 1 + .../getFirstExistingParentPath.spec.ts | 36 ++++++++++++++----- 5 files changed, 67 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index d775afa..6d0d603 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@typescript-eslint/eslint-plugin": "5.59.6", "@typescript-eslint/parser": "5.59.6", "ava": "5.2.0", + "cross-env": "^7.0.3", "eslint": "8.41.0", "eslint-plugin-ava": "14.0.0", "eslint-plugin-import": "2.27.5", @@ -2071,6 +2072,24 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -7967,6 +7986,15 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, + "cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.1" + } + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/package.json b/package.json index aa698d8..70ae5cd 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "lint:fix": "eslint --fix .", "typecheck": "tsc --noEmit", "test": "npm-run-all test:coverage lint typecheck", - "test:unit": "NODE_ENV=test TS_NODE_PROJECT='tsconfig.test.json' ava", + "test:unit": "cross-env NODE_ENV=test TS_NODE_PROJECT='tsconfig.test.json' ava", "test:coverage": "nyc --reporter=lcov --reporter=text npm run test:unit --silent" }, "ava": { @@ -50,6 +50,7 @@ "@typescript-eslint/eslint-plugin": "5.59.6", "@typescript-eslint/parser": "5.59.6", "ava": "5.2.0", + "cross-env": "^7.0.3", "eslint": "8.41.0", "eslint-plugin-ava": "14.0.0", "eslint-plugin-import": "2.27.5", diff --git a/src/functions/getFirstExistingParentPath.ts b/src/functions/getFirstExistingParentPath.ts index 56ef1e2..00ba6ce 100644 --- a/src/functions/getFirstExistingParentPath.ts +++ b/src/functions/getFirstExistingParentPath.ts @@ -8,15 +8,19 @@ import Dependencies from '@/src/types/dependencies' * @param dependencies - Dependencies container */ async function getFirstExistingParentPath(directoryPath: string, dependencies: Dependencies): Promise { - let parentDirectoryPath = directoryPath + let parentDirectoryPath = dependencies.pathNormalize(directoryPath) let parentDirectoryFound = await isDirectoryExisting(parentDirectoryPath, dependencies) - while (!parentDirectoryFound) { - parentDirectoryPath = dependencies.pathNormalize(parentDirectoryPath + '/..') + for (let i = 0; i < 4096 && !parentDirectoryFound; ++i) { + const newParentDirectoryPath = dependencies.pathNormalize(parentDirectoryPath + '/..') + if (parentDirectoryPath === newParentDirectoryPath) { + return '' + } + parentDirectoryPath = newParentDirectoryPath parentDirectoryFound = await isDirectoryExisting(parentDirectoryPath, dependencies) } - return parentDirectoryPath + return parentDirectoryPath !== '.' ? parentDirectoryPath : '' } export default getFirstExistingParentPath diff --git a/src/index.ts b/src/index.ts index 75b7aa4..ad83621 100644 --- a/src/index.ts +++ b/src/index.ts @@ -140,6 +140,7 @@ function checkDiskSpace(directoryPath: string, dependencies: Dependencies = { * @param directoryPath - The file/folder path from where we want to know disk space */ async function checkUnix(directoryPath: string): Promise { + console.log('path ', dependencies.pathNormalize(directoryPath), ' sep ', dependencies.pathSep) if (!dependencies.pathNormalize(directoryPath).startsWith(dependencies.pathSep)) { return Promise.reject(new InvalidPathError(`The following path is invalid (should start by ${dependencies.pathSep}): ${directoryPath}`)) } diff --git a/test/functions/getFirstExistingParentPath.spec.ts b/test/functions/getFirstExistingParentPath.spec.ts index 7ffea08..40a0480 100644 --- a/test/functions/getFirstExistingParentPath.spec.ts +++ b/test/functions/getFirstExistingParentPath.spec.ts @@ -1,24 +1,44 @@ +import { normalize } from 'node:path' + import test from 'ava' import { PathLike } from 'fs' import getFirstExistingParentPath from '@/src/functions/getFirstExistingParentPath' import mockDependencies from '@/test/__helpers__/mockDependencies' +const getDependencies = (parentPath: string) => mockDependencies({ + fsAccess: async (directoryPath: PathLike) => directoryPath === parentPath ? Promise.resolve() : Promise.reject(new Error('File does not exists')), +}) test('unix: get first existing parent path', async t => { - const parentPath = '/home/Alex' - const dependencies = mockDependencies({ - fsAccess: async (directoryPath: PathLike) => directoryPath === parentPath ? Promise.resolve() : Promise.reject(new Error('File does not exists')), - }) + const parentPath = normalize('/home/Alex') + const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath('/home/Alex/games/Some/Game', dependencies), parentPath) }) test('unix: get first parent can be the path itself', async t => { - const parentPath = '/home/Alex' - const dependencies = mockDependencies({ - fsAccess: async (directoryPath: PathLike) => directoryPath === parentPath ? Promise.resolve() : Promise.reject(new Error('File does not exists')), - }) + const parentPath = normalize('/home/Alex') + const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) }) + +test('win32: Gets parent to C:\\HyperPlay', async t => { + const parentPath = normalize('C:\\') + const dependencies = getDependencies(parentPath) + t.is(await getFirstExistingParentPath(normalize('C:\\HyperPlay'), dependencies), parentPath) +}) + +test('win32: Returns root folder when called on root folder', async t => { + const parentPath = normalize('C:\\') + const dependencies = getDependencies(parentPath) + t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) +}) + +test('win32: returns empty string when drive does not exist', async t => { + const drivePathThatExists = normalize('C:\\') + const dependencies = getDependencies(drivePathThatExists) + const drivePathThatDoesNotExist = normalize('Z:\\') + t.is(await getFirstExistingParentPath(drivePathThatDoesNotExist, dependencies), '') +}) From 60f46da55056bb69b2962cc873fc94afa8ed2c22 Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Wed, 13 Dec 2023 00:22:01 -0800 Subject: [PATCH 02/12] fix tests on windows --- test/__helpers__/mockDependencies.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/__helpers__/mockDependencies.ts b/test/__helpers__/mockDependencies.ts index 898e33a..94672c0 100644 --- a/test/__helpers__/mockDependencies.ts +++ b/test/__helpers__/mockDependencies.ts @@ -1,4 +1,4 @@ -import { normalize } from 'node:path' +import { normalize, sep } from 'node:path' import { promisify } from 'node:util' import Dependencies from '@/src/types/dependencies' @@ -12,7 +12,7 @@ function mockDependencies(overrides?: Partial, options?: { release: '11.5.0', fsAccess: () => Promise.resolve(), pathNormalize: normalize, - pathSep: '/', + pathSep: sep, cpExecFile: async () => { await promisify(process.nextTick) From 48b36a48dd0ffbef80085c9509432ceec35eab86 Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:29:41 -0800 Subject: [PATCH 03/12] rm console log --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ad83621..75b7aa4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -140,7 +140,6 @@ function checkDiskSpace(directoryPath: string, dependencies: Dependencies = { * @param directoryPath - The file/folder path from where we want to know disk space */ async function checkUnix(directoryPath: string): Promise { - console.log('path ', dependencies.pathNormalize(directoryPath), ' sep ', dependencies.pathSep) if (!dependencies.pathNormalize(directoryPath).startsWith(dependencies.pathSep)) { return Promise.reject(new InvalidPathError(`The following path is invalid (should start by ${dependencies.pathSep}): ${directoryPath}`)) } From 4ec9f3a081bbec4ac06b81708db47de0e27424fb Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:30:06 -0800 Subject: [PATCH 04/12] add variable for failed to get parent dir, add max number of folders variable --- src/functions/getFirstExistingParentPath.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/functions/getFirstExistingParentPath.ts b/src/functions/getFirstExistingParentPath.ts index 00ba6ce..b6db2d4 100644 --- a/src/functions/getFirstExistingParentPath.ts +++ b/src/functions/getFirstExistingParentPath.ts @@ -11,16 +11,28 @@ async function getFirstExistingParentPath(directoryPath: string, dependencies: D let parentDirectoryPath = dependencies.pathNormalize(directoryPath) let parentDirectoryFound = await isDirectoryExisting(parentDirectoryPath, dependencies) - for (let i = 0; i < 4096 && !parentDirectoryFound; ++i) { + const FAILED_TO_FIND_EXISTING_DIRECTORY_VALUE = '' + + /** + * Linux max file path length is 4096 characters. + * With / separators and 1 letter folder names, this gives us a max of ~2048 folders to traverse. + * This is much less error prone than a while loop. + */ + const maxNumberOfFolders = 2048 + for (let i = 0; i < maxNumberOfFolders && !parentDirectoryFound; ++i) { const newParentDirectoryPath = dependencies.pathNormalize(parentDirectoryPath + '/..') if (parentDirectoryPath === newParentDirectoryPath) { - return '' + return FAILED_TO_FIND_EXISTING_DIRECTORY_VALUE } parentDirectoryPath = newParentDirectoryPath parentDirectoryFound = await isDirectoryExisting(parentDirectoryPath, dependencies) } - return parentDirectoryPath !== '.' ? parentDirectoryPath : '' + if (parentDirectoryPath !== '.') { + return parentDirectoryPath + } + + return FAILED_TO_FIND_EXISTING_DIRECTORY_VALUE } export default getFirstExistingParentPath From 600295e4c8515c531c170d75f0abd536e439d9b2 Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:57:59 -0800 Subject: [PATCH 05/12] Update test/functions/getFirstExistingParentPath.spec.ts Co-authored-by: Alexandre Demode --- test/functions/getFirstExistingParentPath.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functions/getFirstExistingParentPath.spec.ts b/test/functions/getFirstExistingParentPath.spec.ts index 40a0480..5dfc51f 100644 --- a/test/functions/getFirstExistingParentPath.spec.ts +++ b/test/functions/getFirstExistingParentPath.spec.ts @@ -6,7 +6,7 @@ import { PathLike } from 'fs' import getFirstExistingParentPath from '@/src/functions/getFirstExistingParentPath' import mockDependencies from '@/test/__helpers__/mockDependencies' -const getDependencies = (parentPath: string) => mockDependencies({ +const getMockedDependencies = (parentPath: string) => mockDependencies({ fsAccess: async (directoryPath: PathLike) => directoryPath === parentPath ? Promise.resolve() : Promise.reject(new Error('File does not exists')), }) From 43f5a0f5b00ed3a80db62dc089116d3bbc0c704c Mon Sep 17 00:00:00 2001 From: Brett <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:06:53 -0800 Subject: [PATCH 06/12] rm hyperplay, add platform check for tests, rm normalize --- .../getFirstExistingParentPath.spec.ts | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/functions/getFirstExistingParentPath.spec.ts b/test/functions/getFirstExistingParentPath.spec.ts index 5dfc51f..d107341 100644 --- a/test/functions/getFirstExistingParentPath.spec.ts +++ b/test/functions/getFirstExistingParentPath.spec.ts @@ -1,4 +1,4 @@ -import { normalize } from 'node:path' +import { platform } from 'node:os' import test from 'ava' import { PathLike } from 'fs' @@ -6,39 +6,44 @@ import { PathLike } from 'fs' import getFirstExistingParentPath from '@/src/functions/getFirstExistingParentPath' import mockDependencies from '@/test/__helpers__/mockDependencies' -const getMockedDependencies = (parentPath: string) => mockDependencies({ + +const getDependencies = (parentPath: string) => mockDependencies({ fsAccess: async (directoryPath: PathLike) => directoryPath === parentPath ? Promise.resolve() : Promise.reject(new Error('File does not exists')), }) -test('unix: get first existing parent path', async t => { - const parentPath = normalize('/home/Alex') +const os = platform() +const isWindows = os === 'win32' +const testIf = (condition: boolean) => (condition ? test : test.skip) + +testIf(!isWindows)('unix: get first existing parent path', async t => { + const parentPath = '/home/Alex' const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath('/home/Alex/games/Some/Game', dependencies), parentPath) }) -test('unix: get first parent can be the path itself', async t => { - const parentPath = normalize('/home/Alex') +testIf(!isWindows)('unix: get first parent can be the path itself', async t => { + const parentPath = '/home/Alex' const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) }) -test('win32: Gets parent to C:\\HyperPlay', async t => { - const parentPath = normalize('C:\\') +testIf(isWindows)('win32: Gets parent to C:\\Alex', async t => { + const parentPath = 'C:\\' const dependencies = getDependencies(parentPath) - t.is(await getFirstExistingParentPath(normalize('C:\\HyperPlay'), dependencies), parentPath) + t.is(await getFirstExistingParentPath('C:\\Alex', dependencies), parentPath) }) -test('win32: Returns root folder when called on root folder', async t => { - const parentPath = normalize('C:\\') +testIf(isWindows)('win32: Returns root folder when called on root folder', async t => { + const parentPath = 'C:\\' const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) }) -test('win32: returns empty string when drive does not exist', async t => { - const drivePathThatExists = normalize('C:\\') +testIf(isWindows)('win32: returns empty string when drive does not exist', async t => { + const drivePathThatExists = 'C:\\' const dependencies = getDependencies(drivePathThatExists) - const drivePathThatDoesNotExist = normalize('Z:\\') + const drivePathThatDoesNotExist = 'Z:\\' t.is(await getFirstExistingParentPath(drivePathThatDoesNotExist, dependencies), '') }) From c85da1e1b454bf70a046d7fb4225e3318c537381 Mon Sep 17 00:00:00 2001 From: Brett Cleary <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:37:38 -0800 Subject: [PATCH 07/12] revert path sep --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 75b7aa4..7782f88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { execFile } from 'node:child_process' import { access } from 'node:fs/promises' import { release } from 'node:os' -import { normalize, sep } from 'node:path' +import { normalize } from 'node:path' import { platform } from 'node:process' import { promisify } from 'node:util' @@ -23,7 +23,7 @@ function checkDiskSpace(directoryPath: string, dependencies: Dependencies = { release: release(), fsAccess: access, pathNormalize: normalize, - pathSep: sep, + pathSep: '/', cpExecFile: promisify(execFile), }): Promise { // Note: This function contains other functions in order From 98775ffe9d920fcf0873a61ce7851d0e2b741054 Mon Sep 17 00:00:00 2001 From: Brett Cleary <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:37:53 -0800 Subject: [PATCH 08/12] add '.' check to early return --- src/functions/getFirstExistingParentPath.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/getFirstExistingParentPath.ts b/src/functions/getFirstExistingParentPath.ts index b6db2d4..d669dcb 100644 --- a/src/functions/getFirstExistingParentPath.ts +++ b/src/functions/getFirstExistingParentPath.ts @@ -21,7 +21,7 @@ async function getFirstExistingParentPath(directoryPath: string, dependencies: D const maxNumberOfFolders = 2048 for (let i = 0; i < maxNumberOfFolders && !parentDirectoryFound; ++i) { const newParentDirectoryPath = dependencies.pathNormalize(parentDirectoryPath + '/..') - if (parentDirectoryPath === newParentDirectoryPath) { + if (parentDirectoryPath === newParentDirectoryPath || parentDirectoryPath === '.') { return FAILED_TO_FIND_EXISTING_DIRECTORY_VALUE } parentDirectoryPath = newParentDirectoryPath From c69f184a7dcc9ea7c71baa7a9fa5dab7504f5457 Mon Sep 17 00:00:00 2001 From: Brett Cleary <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:38:11 -0800 Subject: [PATCH 09/12] update tests to use '/' --- .../getFirstExistingParentPath.spec.ts | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/test/functions/getFirstExistingParentPath.spec.ts b/test/functions/getFirstExistingParentPath.spec.ts index d107341..dd21c9a 100644 --- a/test/functions/getFirstExistingParentPath.spec.ts +++ b/test/functions/getFirstExistingParentPath.spec.ts @@ -1,49 +1,50 @@ -import { platform } from 'node:os' - import test from 'ava' import { PathLike } from 'fs' import getFirstExistingParentPath from '@/src/functions/getFirstExistingParentPath' import mockDependencies from '@/test/__helpers__/mockDependencies' - const getDependencies = (parentPath: string) => mockDependencies({ fsAccess: async (directoryPath: PathLike) => directoryPath === parentPath ? Promise.resolve() : Promise.reject(new Error('File does not exists')), }) -const os = platform() -const isWindows = os === 'win32' -const testIf = (condition: boolean) => (condition ? test : test.skip) - -testIf(!isWindows)('unix: get first existing parent path', async t => { +test('unix: get first existing parent path', async t => { const parentPath = '/home/Alex' const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath('/home/Alex/games/Some/Game', dependencies), parentPath) }) -testIf(!isWindows)('unix: get first parent can be the path itself', async t => { +test('unix: get first parent can be the path itself', async t => { const parentPath = '/home/Alex' const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) }) -testIf(isWindows)('win32: Gets parent to C:\\Alex', async t => { - const parentPath = 'C:\\' +test('unix: get first parent of root is root', async t => { + const parentPath = '/' + const dependencies = getDependencies(parentPath) + + t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) +}) + +test('win32: Gets parent to C:\\Alex', async t => { + // note that 'C:/' will fail on UNIX os's as normalize(C:/Alex/..) = C: not C:/ + const parentPath = 'C:' const dependencies = getDependencies(parentPath) - t.is(await getFirstExistingParentPath('C:\\Alex', dependencies), parentPath) + t.is(await getFirstExistingParentPath('C:/Alex', dependencies), parentPath) }) -testIf(isWindows)('win32: Returns root folder when called on root folder', async t => { - const parentPath = 'C:\\' +test('win32: Returns root folder when called on root folder', async t => { + const parentPath = 'C:/' const dependencies = getDependencies(parentPath) t.is(await getFirstExistingParentPath(parentPath, dependencies), parentPath) }) -testIf(isWindows)('win32: returns empty string when drive does not exist', async t => { - const drivePathThatExists = 'C:\\' +test('win32: returns empty string when drive does not exist', async t => { + const drivePathThatExists = 'C:/' const dependencies = getDependencies(drivePathThatExists) - const drivePathThatDoesNotExist = 'Z:\\' + const drivePathThatDoesNotExist = 'Z:/' t.is(await getFirstExistingParentPath(drivePathThatDoesNotExist, dependencies), '') }) From 72c3f71b740514cb447736b38e3635ea4b65357a Mon Sep 17 00:00:00 2001 From: Brett Cleary <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:49:27 -0800 Subject: [PATCH 10/12] revert mistaken sep removal --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7782f88..75b7aa4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { execFile } from 'node:child_process' import { access } from 'node:fs/promises' import { release } from 'node:os' -import { normalize } from 'node:path' +import { normalize, sep } from 'node:path' import { platform } from 'node:process' import { promisify } from 'node:util' @@ -23,7 +23,7 @@ function checkDiskSpace(directoryPath: string, dependencies: Dependencies = { release: release(), fsAccess: access, pathNormalize: normalize, - pathSep: '/', + pathSep: sep, cpExecFile: promisify(execFile), }): Promise { // Note: This function contains other functions in order From 4cc36da1ab1f4ae18968e671b7502f30cd0e741b Mon Sep 17 00:00:00 2001 From: Brett Cleary <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:50:07 -0800 Subject: [PATCH 11/12] revert sep in mock deps --- test/__helpers__/mockDependencies.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/__helpers__/mockDependencies.ts b/test/__helpers__/mockDependencies.ts index 94672c0..898e33a 100644 --- a/test/__helpers__/mockDependencies.ts +++ b/test/__helpers__/mockDependencies.ts @@ -1,4 +1,4 @@ -import { normalize, sep } from 'node:path' +import { normalize } from 'node:path' import { promisify } from 'node:util' import Dependencies from '@/src/types/dependencies' @@ -12,7 +12,7 @@ function mockDependencies(overrides?: Partial, options?: { release: '11.5.0', fsAccess: () => Promise.resolve(), pathNormalize: normalize, - pathSep: sep, + pathSep: '/', cpExecFile: async () => { await promisify(process.nextTick) From 1ae83c19611857dae8a6fa961668f7f8f9d7cff0 Mon Sep 17 00:00:00 2001 From: Brett Cleary <27568879+BrettCleary@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:51:04 -0800 Subject: [PATCH 12/12] rm cross-env --- package-lock.json | 28 ---------------------------- package.json | 3 +-- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6d0d603..d775afa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "@typescript-eslint/eslint-plugin": "5.59.6", "@typescript-eslint/parser": "5.59.6", "ava": "5.2.0", - "cross-env": "^7.0.3", "eslint": "8.41.0", "eslint-plugin-ava": "14.0.0", "eslint-plugin-import": "2.27.5", @@ -2072,24 +2071,6 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, - "node_modules/cross-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", - "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.1" - }, - "bin": { - "cross-env": "src/bin/cross-env.js", - "cross-env-shell": "src/bin/cross-env-shell.js" - }, - "engines": { - "node": ">=10.14", - "npm": ">=6", - "yarn": ">=1" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -7986,15 +7967,6 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, - "cross-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", - "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", - "dev": true, - "requires": { - "cross-spawn": "^7.0.1" - } - }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/package.json b/package.json index 70ae5cd..aa698d8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "lint:fix": "eslint --fix .", "typecheck": "tsc --noEmit", "test": "npm-run-all test:coverage lint typecheck", - "test:unit": "cross-env NODE_ENV=test TS_NODE_PROJECT='tsconfig.test.json' ava", + "test:unit": "NODE_ENV=test TS_NODE_PROJECT='tsconfig.test.json' ava", "test:coverage": "nyc --reporter=lcov --reporter=text npm run test:unit --silent" }, "ava": { @@ -50,7 +50,6 @@ "@typescript-eslint/eslint-plugin": "5.59.6", "@typescript-eslint/parser": "5.59.6", "ava": "5.2.0", - "cross-env": "^7.0.3", "eslint": "8.41.0", "eslint-plugin-ava": "14.0.0", "eslint-plugin-import": "2.27.5",