-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from robcresswell/feat/support-ignoring-paths
feat: Support ignoring paths
- Loading branch information
Showing
14 changed files
with
191 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { get } from 'https'; | ||
import { debug } from './log'; | ||
|
||
export async function getGlobsToIgnore( | ||
ignoreFileUrl: string, | ||
): Promise<string[]> { | ||
let globs: string[] = []; | ||
|
||
return new Promise((resolve) => { | ||
try { | ||
get(ignoreFileUrl, (response) => { | ||
if (response.statusCode !== 200) { | ||
debug(`No .demsignore file found at ${ignoreFileUrl}`); | ||
resolve([]); | ||
} | ||
|
||
const globChunks: string[] = []; | ||
|
||
response.on('data', (chunk) => { | ||
globChunks.push(chunk); | ||
}); | ||
|
||
response.on('end', () => { | ||
globs = globChunks | ||
.join('') | ||
.split('\n') | ||
.filter(Boolean); | ||
resolve(globs); | ||
}); | ||
}); | ||
} catch { | ||
debug(`Error retrieving .demsignore file at ${ignoreFileUrl}`); | ||
} | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
import { existsSync, rmdirSync, readdirSync, unlinkSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
function deleteDirectory(path: string) { | ||
if (existsSync(path)) { | ||
const dirents = readdirSync(path, { withFileTypes: true }); | ||
dirents.forEach((ent) => { | ||
if (ent.isFile()) { | ||
unlinkSync(resolve(path, ent.name)); | ||
} | ||
|
||
if (ent.isDirectory()) { | ||
deleteDirectory(resolve(path, ent.name)); | ||
} | ||
}); | ||
|
||
rmdirSync(path); | ||
} | ||
} | ||
|
||
/** | ||
* Not an ideal solution, but relatively safe if the tests are not executed in | ||
* parallel, and provides an easier solution than mocking write streams. Note | ||
* that due to performance issues with Jest and parallelism in CircleCI, | ||
* --runInBand is recommended anyway. | ||
*/ | ||
export function removeTestDir() { | ||
const dir = resolve('dems-example'); | ||
if (existsSync(dir)) { | ||
const dirents = readdirSync(dir, { withFileTypes: true }); | ||
dirents.forEach((ent) => { | ||
if (ent.isFile()) { | ||
unlinkSync(resolve(dir, ent.name)); | ||
} | ||
}); | ||
const fixturePaths = ['dems-example', 'dems-fixture-with-ignores']; | ||
|
||
rmdirSync(dir); | ||
} | ||
fixturePaths.forEach((fixturePath) => { | ||
const dir = resolve(fixturePath); | ||
deleteDirectory(dir); | ||
}); | ||
} |
Oops, something went wrong.