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 844aa25 commit a4e1cae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
16 changes: 14 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29857,14 +29857,26 @@ const base64_encoder_1 = __importDefault(__nccwpck_require__(5564));
class Blob {
constructor(path) {
const cwd = (0, cwd_1.getCwd)();
const workspace = (0, cwd_1.getWorkspace)();
// Add GHA cwd
this.absolutePath = path.startsWith(cwd) ? path : (0, node_path_1.join)(cwd, path);
if (cwd.includes(workspace)) {
this.absolutePath = path.startsWith(cwd) ? path : (0, node_path_1.join)(cwd, path);
}
else if (cwd === workspace) {
this.absolutePath = path.startsWith(cwd) ? path : (0, node_path_1.join)(cwd, path);
}
else {
this.absolutePath = (0, node_path_1.join)(cwd, workspace, path);
}
core.debug('Blob.constructor() - this.absolutePath: ' +
JSON.stringify(this.absolutePath));
// Remove GHA cwd
this.path = path.startsWith(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
16 changes: 13 additions & 3 deletions src/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Readable } from 'node:stream'
import { finished } from 'node:stream/promises'
import { FileAddition } from '@octokit/graphql-schema'

import { getCwd } from './utils/cwd'
import { getCwd, getWorkspace } from './utils/cwd'
import Base64Encoder from './stream/base64-encoder'

export class Blob {
Expand All @@ -17,18 +17,28 @@ export class Blob {

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

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

// Remove GHA cwd
this.path = path.startsWith(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 a4e1cae

Please sign in to comment.