utilium 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fs.js +3 -3
- package/package.json +1 -1
- package/src/fs.ts +3 -3
package/dist/fs.js
CHANGED
@@ -152,9 +152,9 @@ export class FolderMap extends FileMap {
|
|
152
152
|
}
|
153
153
|
}
|
154
154
|
export function gitCommitHash(repo = '.') {
|
155
|
-
repo = repo.replaceAll(
|
155
|
+
repo = repo.replaceAll(/\/+/g, '/').replaceAll(/\/$/g, '');
|
156
156
|
const rev = fs
|
157
|
-
.readFileSync(repo + '
|
157
|
+
.readFileSync(repo + '/.git/HEAD')
|
158
158
|
.toString()
|
159
159
|
.trim();
|
160
160
|
if (rev.indexOf(':') === -1) {
|
@@ -162,7 +162,7 @@ export function gitCommitHash(repo = '.') {
|
|
162
162
|
}
|
163
163
|
else {
|
164
164
|
return fs
|
165
|
-
.readFileSync(repo + '
|
165
|
+
.readFileSync(repo + '/.git/' + rev.substring(5))
|
166
166
|
.toString()
|
167
167
|
.trim();
|
168
168
|
}
|
package/package.json
CHANGED
package/src/fs.ts
CHANGED
@@ -218,16 +218,16 @@ export class FolderMap extends FileMap<string> {
|
|
218
218
|
}
|
219
219
|
|
220
220
|
export function gitCommitHash(repo: string = '.'): string {
|
221
|
-
repo = repo.replaceAll(
|
221
|
+
repo = repo.replaceAll(/\/+/g, '/').replaceAll(/\/$/g, '');
|
222
222
|
const rev = fs
|
223
|
-
.readFileSync(repo + '
|
223
|
+
.readFileSync(repo + '/.git/HEAD')
|
224
224
|
.toString()
|
225
225
|
.trim();
|
226
226
|
if (rev.indexOf(':') === -1) {
|
227
227
|
return rev;
|
228
228
|
} else {
|
229
229
|
return fs
|
230
|
-
.readFileSync(repo + '
|
230
|
+
.readFileSync(repo + '/.git/' + rev.substring(5))
|
231
231
|
.toString()
|
232
232
|
.trim();
|
233
233
|
}
|