Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
xakraz committed Oct 29, 2024
1 parent 1c89da0 commit 3e73972
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
19 changes: 7 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29858,25 +29858,20 @@ class Blob {
constructor(path) {
const cwd = (0, cwd_1.getCwd)();
const workspace = (0, cwd_1.getWorkspace)();
// Add GHA cwd
if (cwd.includes(workspace)) {
this.absolutePath = path.startsWith(cwd) ? path : (0, node_path_1.join)(cwd, path);
}
else if (cwd === workspace) {
if (cwd === workspace || cwd.includes(workspace)) {
this.absolutePath = path.startsWith(cwd) ? path : (0, node_path_1.join)(cwd, path);
this.path = path.startsWith(cwd)
? path.replace(new RegExp(cwd, 'g'), '')
: path;
}
else {
this.absolutePath = (0, node_path_1.join)(cwd, workspace, path);
this.path = path.startsWith(workspace)
? path.replace(new RegExp(workspace, 'g'), '')
: path;
}
core.debug('Blob.constructor() - this.absolutePath: ' +
JSON.stringify(this.absolutePath));
// Remove GHA cwd
const tmpPath = path.startsWith(cwd)
? path.replace(new RegExp(cwd, 'g'), '')
: path;
this.path = tmpPath.startsWith(workspace)
? tmpPath.replace(new RegExp(workspace, 'g'), '')
: tmpPath;
core.debug('Blob.constructor() - this.path: ' + JSON.stringify(this.path));
}
get streamable() {
Expand Down
23 changes: 9 additions & 14 deletions src/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,30 @@ import { getCwd, getWorkspace } from './utils/cwd'
import Base64Encoder from './stream/base64-encoder'

export class Blob {
// Returned as a property of FileChange object
path: string
// Used for content access
absolutePath: string
// Returned as a property of FileChange object
path: string

constructor(path: string) {
const cwd = getCwd()
const workspace = getWorkspace()

// Add GHA cwd
if (cwd.includes(workspace)) {
this.absolutePath = path.startsWith(cwd) ? path : join(cwd, path)
} else if (cwd === workspace) {
if (cwd === workspace || cwd.includes(workspace)) {
this.absolutePath = path.startsWith(cwd) ? path : join(cwd, path)
this.path = path.startsWith(cwd)
? path.replace(new RegExp(cwd, 'g'), '')
: path
} else {
this.absolutePath = join(cwd, workspace, path)
this.path = path.startsWith(workspace)
? path.replace(new RegExp(workspace, 'g'), '')
: path
}
core.debug(
'Blob.constructor() - this.absolutePath: ' +
JSON.stringify(this.absolutePath)
)

// Remove GHA cwd
const tmpPath = path.startsWith(cwd)
? path.replace(new RegExp(cwd, 'g'), '')
: path
this.path = tmpPath.startsWith(workspace)
? tmpPath.replace(new RegExp(workspace, 'g'), '')
: tmpPath
core.debug('Blob.constructor() - this.path: ' + JSON.stringify(this.path))
}

Expand Down

0 comments on commit 3e73972

Please sign in to comment.