-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrite and optimize for real-world usage (no longer supports e…
…nv vars, uses static constant variables)
- Loading branch information
Showing
4 changed files
with
100 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,8 @@ | |
"Philipp Kursawe <[email protected]> (https://pke.github.io)" | ||
], | ||
"dependencies": { | ||
"ip": "^1.1.8", | ||
"last-commit-log": "^3.3.0", | ||
"ip": "^2.0.1", | ||
"last-commit-log": "^3.4.0", | ||
"lodash": "^4.17.21", | ||
"read-pkg-up": "7", | ||
"semver": "^7.5.0" | ||
|
@@ -38,7 +38,6 @@ | |
"remark-cli": "^11.0.0", | ||
"remark-preset-github": "^4.0.4", | ||
"rimraf": "^5.0.0", | ||
"testdouble": "3.17.2", | ||
"xo": "^0.54.2" | ||
}, | ||
"engines": { | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,26 @@ | ||
const process = require('node:process'); | ||
const test = require('ava'); | ||
const td = require('testdouble'); | ||
const LastCommitLog = require('last-commit-log'); | ||
|
||
const lastCommitLog = new LastCommitLog(); | ||
let hash; | ||
let gitTag; | ||
try { | ||
({ hash, gitTag } = lastCommitLog.getLastCommitSync()); | ||
} catch {} | ||
|
||
test.beforeEach((t) => { | ||
t.context.LastCommitLog = td.replace('last-commit-log'); | ||
t.context.parseAppInfo = require('..'); | ||
}); | ||
|
||
test.afterEach(() => { | ||
td.reset(); | ||
}); | ||
|
||
test('does not include missing git info', (t) => { | ||
td.when(t.context.LastCommitLog.prototype.getLastCommitSync()).thenReturn({}); | ||
const appInfo = t.context.parseAppInfo(); | ||
t.is(appInfo.hash, undefined); | ||
t.is(appInfo.tag, undefined); | ||
}); | ||
|
||
test('does not include missing git tag', (t) => { | ||
td.when(t.context.LastCommitLog.prototype.getLastCommitSync()).thenReturn({ | ||
hash: 0xd_ea_db_ea_dd_00_de | ||
}); | ||
const appInfo = t.context.parseAppInfo(); | ||
t.is(appInfo.hash, 0xd_ea_db_ea_dd_00_de); | ||
t.is(appInfo.tag, undefined); | ||
}); | ||
|
||
test('returns this packages info', (t) => { | ||
td.when(t.context.LastCommitLog.prototype.getLastCommitSync()).thenReturn({ | ||
hash: 0xd_ea_db_ea_dd_00_de, | ||
gitTag: '1.0.2' | ||
}); | ||
test('returns info', (t) => { | ||
const appInfo = t.context.parseAppInfo(); | ||
t.is(appInfo.node, process.version); | ||
t.is(appInfo.environment, 'test'); | ||
t.is(appInfo.hostname, require('node:os').hostname()); | ||
t.is(appInfo.pid, process.pid); | ||
t.is(appInfo.name, 'parse-app-info'); | ||
t.is(appInfo.hash, 0xd_ea_db_ea_dd_00_de); | ||
t.is(appInfo.tag, '1.0.2'); | ||
t.is(appInfo.hash, hash); | ||
t.is(appInfo.tag, gitTag); | ||
t.is(appInfo.ip, require('ip').address()); | ||
}); |