Skip to content

Commit b930d9e

Browse files
committed
Added support for .deployignore file
Signed-off-by: Seb Julliand <[email protected]>
1 parent 273f3ef commit b930d9e

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

src/testing/deployTools.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class File {
2525
remotePath?: string;
2626

2727
constructor(readonly name: string, content?: string[]) {
28-
if(content) {
28+
if (content) {
2929
this.content = content;
3030
} else {
3131
this.changeContent();
@@ -162,13 +162,45 @@ export const DeployToolsSuite: TestSuite = {
162162
};
163163

164164
await CompileTools.runAction(instance, vscode.Uri.joinPath(fakeProject.localPath!, "hello.txt"), action);
165-
165+
166166
const localRoot = vscode.workspace.getWorkspaceFolder(fakeProject.localPath!)?.uri;
167167
assert.ok(localRoot, "No workspace folder");
168168
assert.ok(existsSync(vscode.Uri.joinPath(localRoot, `random`, `random.txt`).fsPath));
169169
assert.ok(existsSync(vscode.Uri.joinPath(localRoot, "hello.txt").fsPath));
170170
}
171171
},
172+
{
173+
name: `Test .deployignore`, test: async () => {
174+
const workspace = vscode.workspace.workspaceFolders![0];
175+
const getRootFile = (name: string) => vscode.Uri.joinPath(workspace.uri, name);
176+
const prepare = async (name: string, rollback?: boolean) => {
177+
const file = getRootFile(rollback ? `${name}_backup` : name);
178+
if (existsSync(file.fsPath)) {
179+
await vscode.workspace.fs.rename(file, getRootFile(rollback ? name : `${name}_backup`), { overwrite: true });
180+
}
181+
return file;
182+
};
183+
184+
try {
185+
const toIgnore = ["ignore1", "ignore2", "ignore3", "ignore4", ".gitignore", ".deployignore", ".notignored"];
186+
187+
const deployignore = await prepare(".deployignore");
188+
vscode.workspace.fs.writeFile(deployignore, Buffer.from("**/ignore2\n**/ignore4"));
189+
const ignoreDeploy = await DeployTools.getDefaultIgnoreRules(workspace);
190+
assert.strictEqual(ignoreDeploy.filter(toIgnore).join(","), "ignore1,ignore3,.notignored");
191+
await vscode.workspace.fs.delete(deployignore);
192+
193+
const gitignore = await prepare(".gitignore");
194+
await vscode.workspace.fs.writeFile(gitignore, Buffer.from("**/ignore1\n**/ignore3"));
195+
const ignoreGit = await DeployTools.getDefaultIgnoreRules(workspace);
196+
assert.strictEqual(ignoreGit.filter(toIgnore).join(","), "ignore2,ignore4,.notignored");
197+
}
198+
finally {
199+
await prepare(".gitignore", true);
200+
await prepare(".deployignore", true);
201+
}
202+
}
203+
},
172204
],
173205
after: async () => {
174206
if (fakeProject.localPath && existsSync(fakeProject.localPath.fsPath)) {

0 commit comments

Comments
 (0)