Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with absolute paths and getDestPath #171

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3018,6 +3018,19 @@ describe('index', () => {
});

describe('getDestPath', () => {
it('handles absolute paths properly', () => {
expect(
rokuDeploy.getDestPath(
s`${tempDir}/rootDir/source/main.bs`,
[{
src: `${tempDir}/rootDir/source/main.bs`,
dest: 'source/standalone.brs'
}],
`${tempDir}/src/lsp/standalone-project-1`
)
).to.equal(s`source/standalone.brs`);
});

it('handles unrelated exclusions properly', () => {
expect(
rokuDeploy.getDestPath(
Expand Down
12 changes: 5 additions & 7 deletions src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,11 @@ export class RokuDeploy {

function makeGlobAbsolute(pattern: string) {
return path.resolve(
path.posix.join(
rootDir,
//remove leading exclamation point if pattern is negated
pattern
//coerce all slashes to forward
)
).replace(/\\/g, '/');
rootDir,
//remove leading exclamation point if pattern is negated
pattern
//coerce all slashes to forward
).replace(/\\+/g, '/');
}

let result: string;
Expand Down