mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
13d3039c7d
Since the Bazel setup in this repo will now always use ESM, the tooling scripts/binaries in AIO need to be switched to ESM too. Most of the scripts are already ESM, but a few had to be converted. Note that the Dgeni generation does not use ESM because it's unaffected and the Dgeni CLI is used. In the future we could also update the Dgeni setup to ESM but there is no need currently. PR Close #48521
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
/* eslint no-console: "off" */
|
|
import watchr from 'watchr';
|
|
import canonicalPath from 'canonical-path';
|
|
import authorsPackage from './index.js';
|
|
import config from '../config.js';
|
|
|
|
function listener(changeType, fullPath) {
|
|
try {
|
|
const relativePath = canonicalPath.relative(config.PROJECT_ROOT, fullPath);
|
|
console.log('The file', relativePath, `was ${changeType}d at`, new Date().toUTCString());
|
|
authorsPackage.generateDocs(relativePath);
|
|
} catch (err) {
|
|
console.log('Error generating docs', err);
|
|
}
|
|
}
|
|
|
|
function next(error) {
|
|
if (error) {
|
|
console.log(error);
|
|
}
|
|
}
|
|
|
|
function watch() {
|
|
console.log('============================================================================');
|
|
console.log('Started watching files in:');
|
|
console.log(' - ', config.CONTENTS_PATH);
|
|
console.log(' - ', config.API_SOURCE_PATH);
|
|
console.log('Doc gen will automatically run on any change to a file in either directory.');
|
|
console.log('============================================================================');
|
|
|
|
watchr.open(config.CONTENTS_PATH, listener, next);
|
|
watchr.open(config.API_SOURCE_PATH, listener, next);
|
|
}
|
|
|
|
exports.watch = watch;
|