Compare commits

...

55 Commits

Author SHA1 Message Date
Vallie Joseph 4e88f1375d updating test 2023-03-14 13:27:35 +00:00
Vallie Joseph 992d977c74 Merge branch 'users/cory-miller/test-validate' into users/vmjoseph/rmrf-windows-os-fix 2023-03-14 13:24:22 +00:00
Vallie Joseph 035a7bbf6e Adding force exit 2023-03-14 04:20:38 +00:00
Vallie Joseph 9437454416 formatting 2023-03-14 04:15:42 +00:00
Vallie Joseph 6fae5a046b updating lock 2023-03-14 04:09:24 +00:00
Vallie Joseph 6bb14c42ee Adding version check 2023-03-14 03:52:20 +00:00
Vallie Joseph 9f3f840120 adding tests 2023-03-14 03:35:11 +00:00
Cory Miller 7cbe5b9470 . 2023-03-13 16:39:43 +00:00
Cory Miller 59ec9d07a4 . 2023-03-13 16:35:29 +00:00
Cory Miller 8e804e9f8d locks 2023-03-13 16:07:26 +00:00
Cory Miller 63de74f29d . 2023-02-23 17:29:55 +00:00
Cory Miller 665b756702 try rmSync 2023-02-23 17:26:31 +00:00
Cory Miller 91f0c9b7d0 remove imports as well 2023-02-23 16:03:16 +00:00
Cory Miller 58890d888d remove exec file 2023-02-23 16:03:01 +00:00
Cory Miller b0377621eb just use node's rmrf 2023-02-23 15:48:03 +00:00
Cory Miller 9ff7fcb0e5 . 2023-02-22 15:54:19 +00:00
Cory Miller eed631025c . 2023-02-22 15:48:52 +00:00
Cory Miller d589c08bf4 . 2023-02-22 15:33:29 +00:00
Cory Miller 683cee159e . 2023-02-21 20:00:47 +00:00
Cory Miller 1e057c1e35 . 2023-02-21 19:44:40 +00:00
Cory Miller 5261f00994 . 2023-02-21 19:36:20 +00:00
Cory Miller 1f17f8bd0b . 2023-02-21 19:29:08 +00:00
Cory Miller 19e20568d3 . 2023-02-21 19:14:17 +00:00
Cory Miller e1ed8690d9 . 2023-02-21 18:59:31 +00:00
Cory Miller 6de6f42334 . 2023-02-21 18:51:47 +00:00
Cory Miller 4d807985ec . 2023-02-21 18:44:45 +00:00
Cory Miller 5a97107fca retires 2023-02-21 18:34:11 +00:00
Cory Miller c07cd3b44d . 2023-02-21 18:26:19 +00:00
Cory Miller fe0fbdccde test debug 2023-02-21 17:19:17 +00:00
Cory Miller 4272cd6ca1 . 2023-02-21 17:00:46 +00:00
Cory Miller 9529f35ffd switch to fs.rm 2023-02-21 16:50:10 +00:00
Cory Miller 5dde1c4cf6 add some more debug 2023-02-21 16:34:04 +00:00
Cory Miller 7a5a1c3d42 try inlining inputPath 2023-02-21 16:02:26 +00:00
Cory Miller bcf8127e13 remove err.code 2023-02-21 15:43:50 +00:00
Cory Miller a9ce8db226 add error handler 2023-02-21 15:40:11 +00:00
Cory Miller ed5722cdf7 lint 2023-02-21 15:33:28 +00:00
Cory Miller f1e183e98c revert shell change 2023-02-21 15:32:45 +00:00
Cory Miller d155e954a1 add debug for code 2023-02-21 15:27:48 +00:00
Cory Miller 3406ce58d6 separate args 2023-02-21 15:12:35 +00:00
Cory Miller b0ce9247be try shell true 2023-02-17 21:26:06 +00:00
Cory Miller 5ff5e4f9f0 . 2023-02-17 21:19:50 +00:00
Cory Miller f6011790d6 print spawnargs 2023-02-17 21:15:21 +00:00
Cory Miller 4f66571667 command escaping 2023-02-17 20:58:42 +00:00
Cory Miller b0f4d114f3 why are files still there 2023-02-17 20:53:21 +00:00
Cory Miller a25a620745 ls 2023-02-17 20:46:34 +00:00
Cory Miller 6a3c62d3a8 try ignore eperm 2023-02-17 20:37:22 +00:00
Cory Miller 6a357de342 await on exists 2023-02-17 20:30:21 +00:00
Cory Miller 8d2f32e652 only unlink if still exists 2023-02-17 20:24:10 +00:00
Cory Miller 35cba88c68 windows... 2023-02-17 20:09:53 +00:00
Cory Miller 6a330f08c2 add debug logs 2023-02-17 20:04:49 +00:00
Cory Miller 068db23ad8 add debug logs 2023-02-17 19:58:32 +00:00
Cory Miller 143b802c0a try quiet mode 2023-02-17 19:48:08 +00:00
Cory Miller f13d18d494 lint fixes 2023-02-17 18:36:02 +00:00
Cory Miller 41350470e5 remove semicolon 2023-02-17 18:30:40 +00:00
Cory Miller a730b5ca5f try awaiting spawn on windows 2023-02-17 18:26:26 +00:00
6 changed files with 81 additions and 108 deletions

42
package-lock.json generated
View File

@ -5,6 +5,9 @@
"packages": {
"": {
"name": "root",
"dependencies": {
"package-lock-only": "^0.0.4"
},
"devDependencies": {
"@types/jest": "^27.0.2",
"@types/node": "^16.18.1",
@ -5450,7 +5453,6 @@
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"dependencies": {
"color-convert": "^1.9.0"
},
@ -6152,7 +6154,6 @@
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"dev": true,
"dependencies": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
@ -6354,7 +6355,6 @@
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"dependencies": {
"color-name": "1.1.3"
}
@ -6362,8 +6362,7 @@
"node_modules/color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
"node_modules/color-support": {
"version": "1.1.3",
@ -7406,7 +7405,6 @@
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true,
"engines": {
"node": ">=0.8.0"
}
@ -8909,7 +8907,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true,
"engines": {
"node": ">=4"
}
@ -14404,6 +14401,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/package-lock-only": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/package-lock-only/-/package-lock-only-0.0.4.tgz",
"integrity": "sha512-fV1YHeTMWH5LKmdVqfWskm2/SG0iF2IrxJn3ziaPVx9CnpecGJzt8xXtLV+CYINENZwPFMtbxO5qupz0asNz1A==",
"hasInstallScript": true,
"dependencies": {
"chalk": "^2.4.1"
}
},
"node_modules/pacote": {
"version": "13.6.2",
"resolved": "https://registry.npmjs.org/pacote/-/pacote-13.6.2.tgz",
@ -15758,7 +15764,6 @@
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"dependencies": {
"has-flag": "^3.0.0"
},
@ -21187,7 +21192,6 @@
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
@ -21719,7 +21723,6 @@
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
@ -21871,7 +21874,6 @@
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
@ -21879,8 +21881,7 @@
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
"color-support": {
"version": "1.1.3",
@ -22680,8 +22681,7 @@
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"escodegen": {
"version": "2.0.0",
@ -23831,8 +23831,7 @@
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
},
"has-symbols": {
"version": "1.0.0",
@ -27986,6 +27985,14 @@
"p-reduce": "^2.0.0"
}
},
"package-lock-only": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/package-lock-only/-/package-lock-only-0.0.4.tgz",
"integrity": "sha512-fV1YHeTMWH5LKmdVqfWskm2/SG0iF2IrxJn3ziaPVx9CnpecGJzt8xXtLV+CYINENZwPFMtbxO5qupz0asNz1A==",
"requires": {
"chalk": "^2.4.1"
}
},
"pacote": {
"version": "13.6.2",
"resolved": "https://registry.npmjs.org/pacote/-/pacote-13.6.2.tgz",
@ -29006,7 +29013,6 @@
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}

View File

@ -11,7 +11,7 @@
"lint": "eslint packages/**/*.ts",
"lint-fix": "eslint packages/**/*.ts --fix",
"new-package": "scripts/create-package",
"test": "jest --testTimeout 10000"
"test": "jest --testTimeout 10000 --forceExit"
},
"devDependencies": {
"@types/jest": "^27.0.2",
@ -28,5 +28,8 @@
"prettier": "^1.19.1",
"ts-jest": "^27.0.5",
"typescript": "^3.9.9"
},
"dependencies": {
"package-lock-only": "^0.0.4"
}
}

30
packages/cache/package-lock.json generated vendored
View File

@ -9,11 +9,7 @@
"version": "3.2.1",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.1",
"@azure/abort-controller": "^1.1.0",
"@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.13.0",
@ -43,14 +39,6 @@
"uuid": "dist/bin/uuid"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/glob": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.1.0.tgz",
@ -68,11 +56,6 @@
"tunnel": "^0.0.6"
}
},
"node_modules/@actions/io": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz",
"integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw=="
},
"node_modules/@azure/abort-controller": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
@ -628,14 +611,6 @@
}
}
},
"@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"requires": {
"@actions/io": "^1.0.1"
}
},
"@actions/glob": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.1.0.tgz",
@ -653,11 +628,6 @@
"tunnel": "^0.0.6"
}
},
"@actions/io": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz",
"integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw=="
},
"@azure/abort-controller": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",

View File

@ -3,9 +3,14 @@ import {promises as fs} from 'fs'
import * as os from 'os'
import * as path from 'path'
import * as io from '../src/io'
import * as ioUtil from '../src/io-util'
describe('cp', () => {
beforeAll(async () => {
beforeEach(async () => {
await io.mkdirP(getTestTemp())
})
afterEach(async () => {
await io.rmRF(getTestTemp())
})
@ -192,7 +197,11 @@ describe('cp', () => {
})
describe('mv', () => {
beforeAll(async () => {
beforeEach(async () => {
await io.mkdirP(getTestTemp())
})
afterEach(async () => {
await io.rmRF(getTestTemp())
})
@ -294,7 +303,11 @@ describe('mv', () => {
})
describe('rmRF', () => {
beforeAll(async () => {
beforeEach(async () => {
await io.mkdirP(getTestTemp())
})
afterEach(async () => {
await io.rmRF(getTestTemp())
})
@ -326,15 +339,25 @@ describe('rmRF', () => {
await io.mkdirP(testPath)
await assertExists(testPath)
// can't remove folder with locked file on windows
const filePath = path.join(testPath, 'file.txt')
await fs.appendFile(filePath, 'some data')
await assertExists(filePath)
const fd = await fs.open(filePath, 'r')
const fd = await fs.open(filePath, fs.constants.O_RDONLY | 0x10000000)
await io.rmRF(testPath)
await assertNotExists(testPath)
// // can't remove folder with locked file on windows
if (ioUtil.IS_WINDOWS) {
try {
// additionally, can't stat an open file on Windows without getting EPERM
await io.rmRF(testPath)
} catch (err) {
expect(err.code).toBe('EPERM')
}
} else {
await io.rmRF(testPath)
await assertNotExists(testPath)
}
await fd.close()
await io.rmRF(testPath)
@ -737,7 +760,11 @@ describe('rmRF', () => {
})
describe('mkdirP', () => {
beforeAll(async () => {
beforeEach(async () => {
await io.mkdirP(getTestTemp())
})
afterEach(async () => {
await io.rmRF(getTestTemp())
})
@ -875,7 +902,11 @@ describe('mkdirP', () => {
})
describe('which', () => {
beforeAll(async () => {
beforeEach(async () => {
await io.mkdirP(getTestTemp())
})
afterEach(async () => {
await io.rmRF(getTestTemp())
})
@ -1412,7 +1443,11 @@ describe('which', () => {
})
describe('findInPath', () => {
beforeAll(async () => {
beforeEach(async () => {
await io.mkdirP(getTestTemp())
})
afterEach(async () => {
await io.rmRF(getTestTemp())
})

View File

@ -1,7 +1,7 @@
import * as fs from 'fs'
import * as path from 'path'
export const {
access,
chmod,
copyFile,
lstat,
@ -10,12 +10,14 @@ export const {
readlink,
rename,
rmdir,
rm,
stat,
symlink,
unlink
} = fs.promises
export const IS_WINDOWS = process.platform === 'win32'
export const UV_FS_O_EXLOCK = 0x10000000
export async function exists(fsPath: string): Promise<boolean> {
try {

View File

@ -1,12 +1,7 @@
import {ok} from 'assert'
import * as childProcess from 'child_process'
import * as path from 'path'
import {promisify} from 'util'
import * as ioUtil from './io-util'
const exec = promisify(childProcess.exec)
const execFile = promisify(childProcess.execFile)
/**
* Interface for cp/mv options
*/
@ -116,9 +111,6 @@ export async function mv(
*/
export async function rmRF(inputPath: string): Promise<void> {
if (ioUtil.IS_WINDOWS) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
// Check for invalid characters
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
if (/[*"<>|]/.test(inputPath)) {
@ -126,48 +118,13 @@ export async function rmRF(inputPath: string): Promise<void> {
'File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'
)
}
try {
const cmdPath = ioUtil.getCmdPath()
if (await ioUtil.isDirectory(inputPath, true)) {
await exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
env: {inputPath}
})
} else {
await exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
env: {inputPath}
})
}
} catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT') throw err
}
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
try {
await ioUtil.unlink(inputPath)
} catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT') throw err
}
} else {
let isDir = false
try {
isDir = await ioUtil.isDirectory(inputPath)
} catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT') throw err
return
}
if (isDir) {
await execFile(`rm`, [`-rf`, `${inputPath}`])
} else {
await ioUtil.unlink(inputPath)
}
}
ioUtil.rm(inputPath, {
force: true,
maxRetries: 3,
recursive: true,
retryDelay: 300
})
}
/**