-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmoke.test.js
More file actions
26 lines (24 loc) · 949 Bytes
/
Copy pathsmoke.test.js
File metadata and controls
26 lines (24 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const test = require("node:test");
const assert = require("node:assert");
const { execFileSync } = require("node:child_process");
const fs = require("node:fs");
const path = require("node:path");
test("smoke: package main entry exists and parses", () => {
const pkg = require(path.join(__dirname, "..", "package.json"));
assert.ok(pkg.name, "package.json has a name");
const main = pkg.main || "index.js";
const cli = pkg.bin ? Object.values(pkg.bin)[0] : null;
const entry = cli || main;
if (fs.existsSync(path.join(__dirname, "..", entry))) {
assert.doesNotThrow(
() => execFileSync("node", ["--check", entry], { stdio: "ignore" }),
`${entry} must be valid JavaScript`
);
}
});
test("smoke: required repo files present", () => {
const root = path.join(__dirname, "..");
for (const f of ["package.json", "README.md", "LICENSE"]) {
assert.ok(fs.existsSync(path.join(root, f)), `${f} must exist`);
}
});