Merge pull request #29728 from bwwhite/fsdelete-dotfiles
Let fs:delete wildcard patterns match paths that start with "."
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Fixed bug in fs:delete that prevented wildcard patterns from matching paths starting with "."
|
||||
+15
@@ -48,4 +48,19 @@ export const examples: TemplateExample[] = [
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
description: 'Delete all files in workspace',
|
||||
example: yaml.stringify({
|
||||
steps: [
|
||||
{
|
||||
action: 'fs:delete',
|
||||
id: 'deleteFiles',
|
||||
name: 'Delete files',
|
||||
input: {
|
||||
files: ['**'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
+66
-2
@@ -40,8 +40,14 @@ describe('fs:delete', () => {
|
||||
[workspacePath]: {
|
||||
'unit-test-a.js': 'hello',
|
||||
'unit-test-b.js': 'world',
|
||||
'a-folder': {
|
||||
'unit-test-in-a-folder.js2': 'content',
|
||||
'.dotfile': 'content',
|
||||
'.dotdir': {
|
||||
'.dotfile': 'content',
|
||||
'reg-file.js': 'content',
|
||||
},
|
||||
regdir: {
|
||||
'.dotfile': 'content',
|
||||
'reg-file.js': 'content',
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -165,4 +171,62 @@ describe('fs:delete', () => {
|
||||
expect(fileExists).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('. pattern should match nested and hidden files', async () => {
|
||||
const files = [
|
||||
'unit-test-a.js',
|
||||
'unit-test-b.js',
|
||||
'.dotfile',
|
||||
'.dotdir/.dotfile',
|
||||
'.dotdir/reg-file.js',
|
||||
'regdir/.dotfile',
|
||||
'regdir/reg-file.js',
|
||||
];
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = resolvePath(workspacePath, file);
|
||||
const fileExists = fs.existsSync(filePath);
|
||||
expect(fileExists).toBe(true);
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: { files: ['.'] },
|
||||
});
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = resolvePath(workspacePath, file);
|
||||
const fileExists = fs.existsSync(filePath);
|
||||
expect(fileExists).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('** pattern should match nested and hidden files', async () => {
|
||||
const files = [
|
||||
'unit-test-a.js',
|
||||
'unit-test-b.js',
|
||||
'.dotfile',
|
||||
'.dotdir/.dotfile',
|
||||
'.dotdir/reg-file.js',
|
||||
'regdir/.dotfile',
|
||||
'regdir/reg-file.js',
|
||||
];
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = resolvePath(workspacePath, file);
|
||||
const fileExists = fs.existsSync(filePath);
|
||||
expect(fileExists).toBe(true);
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: { files: ['**'] },
|
||||
});
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = resolvePath(workspacePath, file);
|
||||
const fileExists = fs.existsSync(filePath);
|
||||
expect(fileExists).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,6 +61,7 @@ export const createFilesystemDeleteAction = () => {
|
||||
const resolvedPaths = await globby(safeFilepath, {
|
||||
cwd: ctx.workspacePath,
|
||||
absolute: true,
|
||||
dot: true,
|
||||
});
|
||||
|
||||
for (const filepath of resolvedPaths) {
|
||||
|
||||
Reference in New Issue
Block a user