1
0
Fork 0

update directories

pull/1276/head
John Sudol 2022-12-19 17:09:58 +00:00 committed by GitHub
parent 2f31e7278d
commit b802b32103
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -25,16 +25,16 @@ export function getUploadSpecification(
const rootPath = parse(rootDirectory).dir; const rootPath = parse(rootDirectory).dir;
if (!fs.existsSync(rootPath)) { if (!fs.existsSync(rootPath)) {
throw new Error(`Provided rootDirectory ${rootDirectory} does not exist`) throw new Error(`Provided rootDirectory ${rootPath} does not exist`)
} }
if (!fs.lstatSync(rootDirectory).isDirectory()) { if (!fs.lstatSync(rootPath).isDirectory()) {
throw new Error( throw new Error(
`Provided rootDirectory ${rootDirectory} is not a valid directory` `Provided rootDirectory ${rootPath} is not a valid directory`
) )
} }
// Normalize and resolve, this allows for either absolute or relative paths to be used // Normalize and resolve, this allows for either absolute or relative paths to be used
rootDirectory = normalize(rootDirectory) rootDirectory = normalize(rootPath)
rootDirectory = resolve(rootDirectory) rootDirectory = resolve(rootPath)
/* /*
Example to demonstrate behavior Example to demonstrate behavior
@ -63,14 +63,14 @@ export function getUploadSpecification(
// Normalize and resolve, this allows for either absolute or relative paths to be used // Normalize and resolve, this allows for either absolute or relative paths to be used
file = normalize(file) file = normalize(file)
file = resolve(file) file = resolve(file)
if (!file.startsWith(rootDirectory)) { if (!file.startsWith(rootPath)) {
throw new Error( throw new Error(
`The rootDirectory: ${rootDirectory} is not a parent directory of the file: ${file}` `The rootDirectory: ${rootPath} is not a parent directory of the file: ${file}`
) )
} }
// Check for forbidden characters in file paths that will be rejected during upload // Check for forbidden characters in file paths that will be rejected during upload
const uploadPath = file.replace(rootDirectory, '') const uploadPath = file.replace(rootPath, '')
checkArtifactFilePath(uploadPath) checkArtifactFilePath(uploadPath)
/* /*