Skip to content

Commit ca5a3e0

Browse files
GentooXativaJose Vicente Giner
andauthored
fix: fix scm generation when there is no git repository (#8)
Co-authored-by: Jose Vicente Giner <jvginer@gentooxativa.com>
1 parent 103aa6f commit ca5a3e0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ const gitRemote = require('remote-origin-url');
66

77
module.exports = extra => {
88
const { name, version } = pkg;
9-
const scm = {
9+
let scm = {};
10+
11+
if( fs.existsSync(path.join(process.cwd(), '.git'))){
12+
scm = {
1013
remote: gitRemote.sync(),
1114
branch: gitCommit.branch(),
1215
commit: gitCommit.long()
16+
}
1317
}
14-
const timestamp = new Date().toISOString();
1518

19+
const timestamp = new Date().toISOString();
1620
const manifest = { name, version, scm, timestamp, ...extra };
1721
fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2) + '\n', 'utf-8')
18-
}
22+
}

0 commit comments

Comments
 (0)