-
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.
This patch adds the ability for upstream templates to main a `.demsignore` file, which is a list of glob patterns separated by newlines. This is helpful for two reasons; - Skipping specific files that may contain template variables you want to skip; i.e. CI configuration, or UI libraries using handlebars. - Reducing the number of files that will get walked to have their content replaced with mustache variables
- Loading branch information
1 parent
a0b8f9d
commit 49bcabe
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.