-
Notifications
You must be signed in to change notification settings - Fork 0
/
_postbuild.cjs
61 lines (51 loc) · 1.39 KB
/
_postbuild.cjs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');
const writePackage = (json, dest) => {
fs.writeFileSync(path.resolve(__dirname, dest), JSON.stringify(json));
};
const copyFile = (src, dest) => {
fs.copyFileSync(src, path.resolve(__dirname, dest));
};
copyFile('LICENSE', 'dist/LICENSE');
copyFile('README.md', 'dist/README.md');
writePackage(
{
type: 'module'
},
'dist/esm/package.json'
);
const rootPkg = require('./package.json');
writePackage(
{
...rootPkg,
engines: undefined,
files: undefined,
main: 'cjs/index.js',
module: 'esm/index.js',
types: 'types/index.d.js',
husky: undefined,
'lint-staged': undefined,
scripts: undefined,
'standard-version': undefined
},
'dist/package.json'
);
// const commitHash = getCommitHash();
function getCommitHash() {
// const gitHubCommitHash = process.env.GITHUB_SHA && process.env.GITHUB_SHA.split('\n')[0];
// if (gitHubCommitHash) {
// // eslint-disable-next-line
// console.info(`Using env variable GITHUB_SHA for the commit hash, got: ${gitHubCommitHash}`);
// return gitHubCommitHash;
// }
// if (process.env.EXPECT_GITHUB_SHA) {
// if (!gitHubCommitHash) {
// // eslint-disable-next-line
// console.error('No GITHUB_SHA specified');
// process.exit(1);
// }
// }
const out = execSync('git rev-parse HEAD');
return out.toString().split('\n')[0];
}