Skip to content

Commit ab6cdd3

Browse files
committed
make build handle not yet added lessons
1 parent 5322783 commit ab6cdd3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

build/js/build.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,19 @@ var Builder = function(outBaseDir, options) {
390390
data);
391391
});
392392

393-
function utcMomentFromGitLog(result) {
393+
function utcMomentFromGitLog(result, filename, timeType) {
394394
const dateStr = result.stdout.split("\n")[0].trim();
395395
let utcDateStr = dateStr
396396
.replace(/"/g, "") // WTF to these quotes come from!??!
397397
.replace(" ", "T")
398398
.replace(" ", "")
399399
.replace(/(\d\d)$/, ':$1');
400-
return moment.utc(utcDateStr);
400+
const m = moment.utc(utcDateStr);
401+
if (m.isValid()) {
402+
return m;
403+
}
404+
const stat = fs.statSync(filename);
405+
return moment(stat[timeType]);
401406
}
402407

403408
const tasks = g_articles.map((article) => {
@@ -409,7 +414,7 @@ var Builder = function(outBaseDir, options) {
409414
'--diff-filter=A',
410415
article.src_file_name,
411416
]).then((result) => {
412-
article.dateAdded = utcMomentFromGitLog(result);
417+
article.dateAdded = utcMomentFromGitLog(result, article.src_file_name, 'ctime');
413418
});
414419
};
415420
}).concat(g_articles.map((article) => {
@@ -421,7 +426,7 @@ var Builder = function(outBaseDir, options) {
421426
'--max-count=1',
422427
article.src_file_name,
423428
]).then((result) => {
424-
article.dateModified = utcMomentFromGitLog(result);
429+
article.dateModified = utcMomentFromGitLog(result, article.src_file_name, 'mtime');
425430
});
426431
};
427432
}));

0 commit comments

Comments
 (0)