Skip to content

Commit 31e86f4

Browse files
authored
Don't upload ignored stuff during 'vt create' (#181)
* Don't upload ignored stuff during 'vt create' * Nested create vtignore dir * Bump version
1 parent b722e23 commit 31e86f4

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/denoland/deno/348900b8b79f4a434cab4c74b3bc8d4d2fa8ee74/cli/schemas/config-file.v1.json",
33
"name": "@valtown/vt",
44
"description": "The Val Town CLI",
5-
"version": "0.1.43",
5+
"version": "0.1.44",
66
"exports": "./vt.ts",
77
"license": "MIT",
88
"tasks": {

src/cmd/tests/create_test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Deno.test({
5959
"create",
6060
nonEmptyDirValName,
6161
], tmpDir);
62-
console.log(stdout);
6362
assertStringIncludes(
6463
stdout,
6564
"files will be uploaded",
@@ -217,6 +216,15 @@ Deno.test({
217216
join(tmpDir, "another-file.ts"),
218217
"export const value = 42;",
219218
);
219+
await Deno.mkdir(join(tmpDir, "foo"));
220+
await Deno.writeTextFile(
221+
join(tmpDir, "foo/.vtignore"),
222+
"ignored-file.txt",
223+
);
224+
await Deno.writeTextFile(
225+
join(tmpDir, "ignored-file.txt"),
226+
"This file should not be uploaded",
227+
);
220228
});
221229

222230
await t.step("create Val in current directory", async () => {
@@ -258,6 +266,10 @@ Deno.test({
258266
fileNames.includes("another-file.ts"),
259267
"another-file.ts should be uploaded to Val",
260268
);
269+
assert(
270+
!fileNames.includes("ignored-file.txt"),
271+
"ignored-file.txt should be ignored and not uploaded to Val",
272+
);
261273
});
262274
});
263275
},

src/vt/vt/VTClient.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,20 @@ export default class VTClient {
280280
await assertSafeDirectory(rootPath);
281281
}
282282

283+
// If the directory exists, make a VTMeta in it, and gather the gitignore rules
284+
let gitignoreRules: string[] = [];
285+
if (await exists(rootPath)) {
286+
const meta = new VTMeta(rootPath);
287+
gitignoreRules = await meta.loadGitignoreRules();
288+
}
289+
283290
// First create the val (this uploads it too)
284291
const { newValId } = await create({
285292
sourceDir: rootPath,
286293
valName,
287294
privacy,
288295
description,
296+
gitignoreRules,
289297
});
290298

291299
// Get the Val branch

0 commit comments

Comments
 (0)