Skip to content

Commit

Permalink
Make paths relative (apparently necessary when using multiple globs)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercamp committed Dec 17, 2021
1 parent 7c6863a commit 16cda43
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
13 changes: 12 additions & 1 deletion analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ function buildGlobObject(globsArray) {
return glob.create(globsArray.join('\n'))
}

function makeRelative(workingDir, path) {
if (path.indexOf(workingDir) == 0) {
let relative = path.substr(workingDir.length)
if (relative[0] == '/') relative = relative.substr(1)
return relative
} else {
return path
}
}

async function prepareInputsZip(inputsGlob, targetFile) {
const separatedInputGlobs = commaSeparated(inputsGlob);
core.debug("Got input file globs: " + separatedInputGlobs)
Expand All @@ -51,8 +61,9 @@ async function prepareInputsZip(inputsGlob, targetFile) {
archive.pipe(output);

let numWritten = 0
const workingDir = process.cwd()
for await (const file of inputFilesGlob.globGenerator()) {
archive.file(file);
archive.file(makeRelative(workingDir, file))
numWritten += 1
}
await archive.finalize()
Expand Down
13 changes: 12 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ function buildGlobObject(globsArray) {
return glob.create(globsArray.join('\n'))
}

function makeRelative(workingDir, path) {
if (path.indexOf(workingDir) == 0) {
let relative = path.substr(workingDir.length)
if (relative[0] == '/') relative = relative.substr(1)
return relative
} else {
return path
}
}

async function prepareInputsZip(inputsGlob, targetFile) {
const separatedInputGlobs = commaSeparated(inputsGlob);
core.debug("Got input file globs: " + separatedInputGlobs)
Expand All @@ -58,8 +68,9 @@ async function prepareInputsZip(inputsGlob, targetFile) {
archive.pipe(output);

let numWritten = 0
const workingDir = process.cwd()
for await (const file of inputFilesGlob.globGenerator()) {
archive.file(file);
archive.file(makeRelative(workingDir, file))
numWritten += 1
}
await archive.finalize()
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 16cda43

Please sign in to comment.