Skip to content

Commit

Permalink
Added support for .deployignore file
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Julliand <[email protected]>
  • Loading branch information
sebjulliand committed Mar 27, 2024
1 parent 273f3ef commit b930d9e
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/testing/deployTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class File {
remotePath?: string;

constructor(readonly name: string, content?: string[]) {
if(content) {
if (content) {
this.content = content;
} else {
this.changeContent();
Expand Down Expand Up @@ -162,13 +162,45 @@ export const DeployToolsSuite: TestSuite = {
};

await CompileTools.runAction(instance, vscode.Uri.joinPath(fakeProject.localPath!, "hello.txt"), action);

const localRoot = vscode.workspace.getWorkspaceFolder(fakeProject.localPath!)?.uri;
assert.ok(localRoot, "No workspace folder");
assert.ok(existsSync(vscode.Uri.joinPath(localRoot, `random`, `random.txt`).fsPath));
assert.ok(existsSync(vscode.Uri.joinPath(localRoot, "hello.txt").fsPath));
}
},
{
name: `Test .deployignore`, test: async () => {
const workspace = vscode.workspace.workspaceFolders![0];
const getRootFile = (name: string) => vscode.Uri.joinPath(workspace.uri, name);
const prepare = async (name: string, rollback?: boolean) => {
const file = getRootFile(rollback ? `${name}_backup` : name);
if (existsSync(file.fsPath)) {
await vscode.workspace.fs.rename(file, getRootFile(rollback ? name : `${name}_backup`), { overwrite: true });
}
return file;
};

try {
const toIgnore = ["ignore1", "ignore2", "ignore3", "ignore4", ".gitignore", ".deployignore", ".notignored"];

const deployignore = await prepare(".deployignore");
vscode.workspace.fs.writeFile(deployignore, Buffer.from("**/ignore2\n**/ignore4"));
const ignoreDeploy = await DeployTools.getDefaultIgnoreRules(workspace);
assert.strictEqual(ignoreDeploy.filter(toIgnore).join(","), "ignore1,ignore3,.notignored");
await vscode.workspace.fs.delete(deployignore);

const gitignore = await prepare(".gitignore");
await vscode.workspace.fs.writeFile(gitignore, Buffer.from("**/ignore1\n**/ignore3"));
const ignoreGit = await DeployTools.getDefaultIgnoreRules(workspace);
assert.strictEqual(ignoreGit.filter(toIgnore).join(","), "ignore2,ignore4,.notignored");
}
finally {
await prepare(".gitignore", true);
await prepare(".deployignore", true);
}
}
},
],
after: async () => {
if (fakeProject.localPath && existsSync(fakeProject.localPath.fsPath)) {
Expand Down

0 comments on commit b930d9e

Please sign in to comment.