Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e2a9919

Browse files
author
Vasil Chimev
authoredSep 27, 2017
chore: add publish next script (#32)
1 parent 2cd3cbc commit e2a9919

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
 

‎.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66
!/**/*.d.ts
77
e2e/reports
88
!e2e/*.ts
9+
publish-next.js

‎publish-next.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env node
2+
3+
const { readFileSync, writeFileSync } = require("fs");
4+
const { resolve } = require("path");
5+
6+
const getPackageJsonPath = projectDir => resolve(projectDir, "package.json");
7+
const getPackageJson = projectDir => {
8+
const packageJsonPath = getPackageJsonPath(projectDir);
9+
return JSON.parse(readFileSync(packageJsonPath, "utf8"));
10+
}
11+
const writePackageJson = (content, projectDir) => {
12+
const packageJsonPath = getPackageJsonPath(projectDir);
13+
writeFileSync(packageJsonPath, JSON.stringify(content, null, 2));
14+
}
15+
16+
const tag = "next";
17+
const projectDir = __dirname;
18+
const packageJson = getPackageJson(projectDir);
19+
const [, , packageVersion = new Date().toISOString().split("T")[0] ] = process.argv;
20+
21+
packageJson.publishConfig = Object.assign(
22+
packageJson.publishConfig || {},
23+
{ tag }
24+
);
25+
26+
const currentVersion = packageJson.version;
27+
const nextVersion = `${currentVersion}-${packageVersion}`;
28+
const newPackageJson = Object.assign(packageJson, { version: nextVersion });
29+
30+
writePackageJson(newPackageJson, projectDir);

0 commit comments

Comments
 (0)
Please sign in to comment.