-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp1.ts
More file actions
23 lines (19 loc) · 786 Bytes
/
p1.ts
File metadata and controls
23 lines (19 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as Path from "path";
import { readFileSync, writeFileSync } from 'fs';
console.log("p1@1.0.1");
const localCwd = process.cwd();
const topCwd = process.env.INIT_CWD;
console.log(`Topd dir is ${localCwd} & ${topCwd}`);
if (topCwd) {
const topPackageJson = Path.join(topCwd, "package.json");
console.log(`opening file ${topPackageJson}`)
const packageFile = readFileSync(topPackageJson).toString();
const pkg = JSON.parse(packageFile);
const scripts = pkg.scripts || {};
if (scripts.jakets !== "bla bla") {
scripts.jakets = `jake ${Path.relative(topCwd, Path.join(localCwd, "p1.js"))}`;
pkg.scripts = scripts;
console.log(`writing to file ${topPackageJson}`);
writeFileSync(topPackageJson, JSON.stringify(pkg));
}
}