Correctly recognize whether the cookiecutter command exists
Signed-off-by: Dominik Henneke <dominik.henneke@sda-se.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Correctly recognize whether the cookiecutter command exists
|
||||
@@ -35,6 +35,7 @@ describe('CookieCutter Templater', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
commandExists.mockRejectedValue(null);
|
||||
});
|
||||
|
||||
it('should write a cookiecutter.json file with the values from the entity', async () => {
|
||||
@@ -228,7 +229,7 @@ describe('CookieCutter Templater', () => {
|
||||
};
|
||||
|
||||
jest.spyOn(fs, 'readdir').mockResolvedValueOnce(['newthing'] as any);
|
||||
commandExists.mockImplementationOnce(() => () => true);
|
||||
commandExists.mockResolvedValueOnce(true);
|
||||
|
||||
const templater = new CookieCutter({ containerRunner });
|
||||
await templater.run({
|
||||
|
||||
@@ -70,7 +70,10 @@ export class CookieCutter implements TemplaterBase {
|
||||
[intermediateDir]: '/output',
|
||||
};
|
||||
|
||||
const cookieCutterInstalled = await commandExists('cookiecutter');
|
||||
// the command-exists package returns `true` or throws an error
|
||||
const cookieCutterInstalled = await commandExists('cookiecutter').catch(
|
||||
() => false,
|
||||
);
|
||||
if (cookieCutterInstalled) {
|
||||
await runCommand({
|
||||
command: 'cookiecutter',
|
||||
|
||||
Reference in New Issue
Block a user