Skip to content

Commit 16cda43

Browse files
committed
Make paths relative (apparently necessary when using multiple globs)
1 parent 7c6863a commit 16cda43

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

analyze.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ function buildGlobObject(globsArray) {
3434
return glob.create(globsArray.join('\n'))
3535
}
3636

37+
function makeRelative(workingDir, path) {
38+
if (path.indexOf(workingDir) == 0) {
39+
let relative = path.substr(workingDir.length)
40+
if (relative[0] == '/') relative = relative.substr(1)
41+
return relative
42+
} else {
43+
return path
44+
}
45+
}
46+
3747
async function prepareInputsZip(inputsGlob, targetFile) {
3848
const separatedInputGlobs = commaSeparated(inputsGlob);
3949
core.debug("Got input file globs: " + separatedInputGlobs)
@@ -51,8 +61,9 @@ async function prepareInputsZip(inputsGlob, targetFile) {
5161
archive.pipe(output);
5262

5363
let numWritten = 0
64+
const workingDir = process.cwd()
5465
for await (const file of inputFilesGlob.globGenerator()) {
55-
archive.file(file);
66+
archive.file(makeRelative(workingDir, file))
5667
numWritten += 1
5768
}
5869
await archive.finalize()

dist/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ function buildGlobObject(globsArray) {
4141
return glob.create(globsArray.join('\n'))
4242
}
4343

44+
function makeRelative(workingDir, path) {
45+
if (path.indexOf(workingDir) == 0) {
46+
let relative = path.substr(workingDir.length)
47+
if (relative[0] == '/') relative = relative.substr(1)
48+
return relative
49+
} else {
50+
return path
51+
}
52+
}
53+
4454
async function prepareInputsZip(inputsGlob, targetFile) {
4555
const separatedInputGlobs = commaSeparated(inputsGlob);
4656
core.debug("Got input file globs: " + separatedInputGlobs)
@@ -58,8 +68,9 @@ async function prepareInputsZip(inputsGlob, targetFile) {
5868
archive.pipe(output);
5969

6070
let numWritten = 0
71+
const workingDir = process.cwd()
6172
for await (const file of inputFilesGlob.globGenerator()) {
62-
archive.file(file);
73+
archive.file(makeRelative(workingDir, file))
6374
numWritten += 1
6475
}
6576
await archive.finalize()

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)