-
-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathprepublish-next.js
33 lines (25 loc) · 1.01 KB
/
prepublish-next.js
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
27
28
29
30
31
32
33
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const getPackageJson = projectDir => {
const packageJsonPath = getPackageJsonPath(projectDir);
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
};
const writePackageJson = (content, projectDir) => {
const packageJsonPath = getPackageJsonPath(projectDir);
fs.writeFileSync(packageJsonPath, JSON.stringify(content, null, 2))
}
const getPackageJsonPath = projectDir => path.resolve(projectDir, "package.json");
const tag = "next";
const projectDir = "nativescript-angular";
const packageJson = getPackageJson(projectDir);
const [, , packageVersion = new Date() ] = process.argv;
packageJson.publishConfig = Object.assign(
packageJson.publishConfig || {},
{ tag }
);
delete packageJson.private;
const currentVersion = packageJson.version;
const nextVersion = `${currentVersion}-${packageVersion}`;
const newPackageJson = Object.assign(packageJson, { version: nextVersion });
writePackageJson(newPackageJson, projectDir);