Skip to content

Commit

Permalink
Allow negated non-root-dir top-level patterns in files array (#78)
Browse files Browse the repository at this point in the history
* standardize unit tests and remove testProject

* Upgrade typescript and test packages.

* Upgrade eslint and fix some lint issues.

* Bump node version for CI

* Remove unnecessary ts-mocha

* silly fix

* Hit 100% coverage

* fix cwd issue

* Try to fix build

* Remove unused eventemitter3

* Close signed package write stream

* Fix test that was using testProject

* Fix device tests

* Remove testProject

* Remove `as any` casts in tests

* Fix rekey package path

* Fix more tests.

* Allow outside-rootDir negated top-level globs

* Fix test
  • Loading branch information
TwitchBronBron authored Oct 25, 2021
1 parent 1486b40 commit 480e10e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,21 @@ describe('index', () => {
]);
});

it('allows negating paths outside rootDir without requiring src;dest; syntax', async () => {
fsExtra.outputFileSync(`${rootDir}/../externalLib/source/lib.brs`, '');
const filePaths = await getFilePaths([
'source/**/*',
{ src: '../externalLib/**/*', dest: 'source' },
'!../externalLib/source/**/*'
], rootDir);
expect(
filePaths.map(x => s`${x.src}`).sort()
).to.eql([
s`${rootDir}/source/lib.brs`,
s`${rootDir}/source/main.brs`
]);
});

it('applies multi-glob paths relative to rootDir', async () => {
expect(await getFilePaths([
'manifest',
Expand Down Expand Up @@ -2224,6 +2239,18 @@ describe('index', () => {
).to.be.undefined;
});

it('excludes file from non-rootdir top-level pattern', () => {
expect(
rokuDeploy.getDestPath(
s`${rootDir}/../externalDir/source/main.brs`,
[
'!../externalDir/**/*'
],
rootDir
)
).to.be.undefined;
});

it('excludes a file that is negated in src;dest;', () => {
expect(
rokuDeploy.getDestPath(
Expand Down
6 changes: 6 additions & 0 deletions src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ export class RokuDeploy {
//remove the ! so the glob will match properly
if (isNegated) {
src = src.substring(1);
//create the entry as a src;dest; so it doesn't throw that "Cannot reference a file outside of rootDir..." error in `getFilePathsForEntry`.
entry = {
src: src,
// Negated globs don't need a `dest` path but add the key to satisfy the typescript check
dest: undefined
};
}

let entryResults = await this.getFilePathsForEntry(
Expand Down

0 comments on commit 480e10e

Please sign in to comment.