mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-08 01:45:32 +00:00
chore: make const for date format
This commit is contained in:
parent
e9e7d5b85f
commit
ccfefa279f
2 changed files with 6 additions and 3 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import { execFileSync } from 'child_process';
|
||||
|
||||
// RFC3339 pattern, UTC
|
||||
export const expectedGitDateFormat = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$/;
|
||||
|
||||
/**
|
||||
* Returns the date and time of the last commit from git for the passed in path
|
||||
* @param path Path for which to retrieve the last commit message
|
||||
|
|
@ -37,7 +40,7 @@ export function getLastGitCommitDate(path: string): string {
|
|||
|
||||
// We'll only return the result if it walks like a date, swims like a date,
|
||||
// and quacks like a date.
|
||||
if (!result.match(/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$/)) {
|
||||
if (!result.match(expectedGitDateFormat)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { assert } from 'chai';
|
||||
import 'mocha';
|
||||
import { makePathToFixture } from './helpers/index.js';
|
||||
import { getLastGitCommitDate } from '../src/util/getLastGitCommitDate.js';
|
||||
import { expectedGitDateFormat, getLastGitCommitDate } from '../src/util/getLastGitCommitDate.js';
|
||||
|
||||
describe('getLastGitCommitDate', function () {
|
||||
it('should return a valid date for a folder in this repo', async function() {
|
||||
const path = makePathToFixture('.');
|
||||
const date = getLastGitCommitDate(path);
|
||||
assert.match(date, /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$/);
|
||||
assert.match(date, expectedGitDateFormat);
|
||||
});
|
||||
|
||||
it('should return null for a folder outside the repo', async function() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue