Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove tmp #105

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@
"@types/rimraf": "2.0.2",
"@types/semver": "5.5.0",
"@types/tar": "^6.1.3",
"@types/tmp": "^0.2.0",
"@vitest/coverage-v8": "^2.1.8",
"coveralls": "^3.1.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"npm-run-all2": "^7.0.2",
"prettier": "^3.4.2",
"tmp": "0.2.1",
"type-fest": "^0.17.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.18.2",
Expand Down
6 changes: 3 additions & 3 deletions test/commands/defaultconfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import path from "node:path";

import { Command } from "commander";
import fse from "fs-extra";
import temp from "tmp";
import { beforeEach, describe, expect, it, vi } from "vitest";

import defaultConfigCommand from "../../src/commands/defaultconfig";
import { createMockProgram, MockCommand } from "../mocks/program";
import { setupTmpDir } from "./tmp-dir";

let program: MockCommand;

beforeEach(() => {
// Set up environment.
const tempFolder = temp.dirSync();
process.chdir(tempFolder.name);
const tempFolder = setupTmpDir();
process.chdir(tempFolder);
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

// Copy fixtures.
Expand Down
6 changes: 3 additions & 3 deletions test/commands/install.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import fs from "node:fs";
import { Command } from "commander";
import rimraf from "rimraf";
import semver from "semver";
import temp from "tmp";
import { beforeEach, expect, it, vi } from "vitest";

import installCommand from "../../src/commands/install";
import { createMockProgram, MockCommand } from "../mocks/program";
import { setupTmpDir } from "./tmp-dir";

let program: MockCommand;
const tempFolder = temp.dirSync();
process.chdir(tempFolder.name);
const tempFolder = setupTmpDir();
process.chdir(tempFolder);
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

beforeEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions test/commands/schema-types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import fs from "node:fs";
import path from "node:path";

import fse from "fs-extra";
import temp from "tmp";
import { beforeEach, expect, it, vi } from "vitest";

import schemaTypesCommand from "../../src/commands/schema-types";
import { createMockProgram, MockCommand } from "../mocks/program";
import { setupTmpDir } from "./tmp-dir";

let program: MockCommand;

beforeEach(() => {
// Set up environment.
const tempFolder = temp.dirSync();
process.chdir(tempFolder.name);
const tempFolder = setupTmpDir();
process.chdir(tempFolder);
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

// Copy fixtures.
Expand Down
8 changes: 4 additions & 4 deletions test/commands/setup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import fs from "node:fs";

import { Command } from "commander";
import inquirer from "inquirer";
import temp from "tmp";
import { PackageJson } from "type-fest";
import { beforeEach, expect, test, vi } from "vitest";

import setupCommand from "../../src/commands/setup";
import { createMockProgram, MockCommand } from "../mocks/program";
import { setupTmpDir } from "./tmp-dir";

let program: MockCommand;
let currentDir = temp.dirSync();
let currentDir = setupTmpDir();
const chdir = (keepCurrentDir = false) => {
if (!keepCurrentDir) {
currentDir = temp.dirSync();
currentDir = setupTmpDir();
}

process.chdir(currentDir.name);
process.chdir(currentDir);
};

const readPackageJson = (): PackageJson => {
Expand Down
10 changes: 10 additions & 0 deletions test/commands/tmp-dir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { randomUUID } from "node:crypto";
import { mkdirSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";

export function setupTmpDir() {
const dir = path.join(tmpdir(), randomUUID());
mkdirSync(dir);
return dir;
}
6 changes: 3 additions & 3 deletions test/commands/uninstall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import path from "node:path";
import { Command } from "commander";
import fse from "fs-extra";
import inquirer from "inquirer";
import temp from "tmp";
import { beforeEach, expect, it, vi } from "vitest";

import uninstallCommand from "../../src/commands/uninstall";
import { createMockProgram, MockCommand } from "../mocks/program";
import { setupTmpDir } from "./tmp-dir";

let program: MockCommand;

beforeEach(() => {
// Set up environment.
const tempFolder = temp.dirSync();
process.chdir(tempFolder.name);
const tempFolder = setupTmpDir();
process.chdir(tempFolder);
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

// Copy fixtures.
Expand Down
Loading