|
1 | | -const fs = require('fs') |
2 | | -const path = require('path') |
3 | | -const pkg = require(path.join(process.cwd(), 'package.json')) |
| 1 | +const fs = require('fs'); |
| 2 | +const path = require('path'); |
4 | 3 | const gitCommit = require('git-rev-sync'); |
5 | 4 | const gitRemote = require('remote-origin-url'); |
6 | 5 |
|
| 6 | +const pkg = require(path.join(process.cwd(), 'package.json')); |
| 7 | + |
7 | 8 | module.exports = extra => { |
8 | | - const { name, version } = pkg; |
9 | | - let scm = {}; |
| 9 | + const { name, version } = pkg; |
| 10 | + let scm = {}; |
10 | 11 |
|
11 | | - // Without commits, .git/packed-refs does not exists |
12 | | - if( fs.existsSync(path.join(process.cwd(), '.git', 'packed-refs'))){ |
13 | | - scm = { |
14 | | - remote: gitRemote.sync(), |
15 | | - branch: gitCommit.branch(), |
16 | | - commit: gitCommit.long() |
17 | | - } |
| 12 | + // Without commits, .git/packed-refs does not exists |
| 13 | + if (fs.existsSync(path.join(process.cwd(), '.git', 'packed-refs'))) { |
| 14 | + scm = { |
| 15 | + remote: gitRemote.sync(), |
| 16 | + branch: gitCommit.branch(), |
| 17 | + commit: gitCommit.long() |
18 | 18 | } |
| 19 | + } |
| 20 | + |
| 21 | + const timestamp = new Date().toISOString(); |
| 22 | + const manifest = { name, version, scm, timestamp, ...extra }; |
19 | 23 |
|
20 | | - const timestamp = new Date().toISOString(); |
21 | | - const manifest = { name, version, scm, timestamp, ...extra }; |
22 | | - fs.writeFileSync('manifest.json', `${JSON.stringify(manifest, null, 2)}\n`, 'utf-8') |
| 24 | + fs.writeFileSync('manifest.json', `${JSON.stringify(manifest, null, 2)}\n`, 'utf-8'); |
23 | 25 | } |
0 commit comments