chore: use exit code 0 for doclint file gen (#8377)
This commit is contained in:
parent
1ae3da6064
commit
bfed9cd34a
@ -39,6 +39,14 @@ class Message {
|
|||||||
static warning(text) {
|
static warning(text) {
|
||||||
return new Message('warning', text);
|
return new Message('warning', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} text
|
||||||
|
* @returns {!Message}
|
||||||
|
*/
|
||||||
|
static info(text) {
|
||||||
|
return new Message('info', text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Message;
|
module.exports = Message;
|
||||||
|
@ -24,6 +24,7 @@ const PROJECT_DIR = path.join(__dirname, '..', '..');
|
|||||||
const VERSION = require(path.join(PROJECT_DIR, 'package.json')).version;
|
const VERSION = require(path.join(PROJECT_DIR, 'package.json')).version;
|
||||||
|
|
||||||
const RED_COLOR = '\x1b[31m';
|
const RED_COLOR = '\x1b[31m';
|
||||||
|
const BLUE_COLOR = '\x1b[34m';
|
||||||
const YELLOW_COLOR = '\x1b[33m';
|
const YELLOW_COLOR = '\x1b[33m';
|
||||||
const RESET_COLOR = '\x1b[0m';
|
const RESET_COLOR = '\x1b[0m';
|
||||||
|
|
||||||
@ -108,32 +109,40 @@ async function run() {
|
|||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
console.log('DocLint Failures:');
|
console.log('DocLint Failures:');
|
||||||
for (let i = 0; i < errors.length; ++i) {
|
for (let i = 0; i < errors.length; ++i) {
|
||||||
let error = errors[i].text;
|
const text = errors[i].text.split('\n').join('\n ');
|
||||||
error = error.split('\n').join('\n ');
|
console.log(` ${i + 1}) ${RED_COLOR}${text}${RESET_COLOR}`);
|
||||||
console.log(` ${i + 1}) ${RED_COLOR}${error}${RESET_COLOR}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const warnings = messages.filter((message) => message.type === 'warning');
|
const warnings = messages.filter((message) => message.type === 'warning');
|
||||||
if (warnings.length) {
|
if (warnings.length) {
|
||||||
console.log('DocLint Warnings:');
|
console.log('DocLint Warnings:');
|
||||||
for (let i = 0; i < warnings.length; ++i) {
|
for (let i = 0; i < warnings.length; ++i) {
|
||||||
let warning = warnings[i].text;
|
const text = warnings[i].text.split('\n').join('\n ');
|
||||||
warning = warning.split('\n').join('\n ');
|
console.log(` ${i + 1}) ${YELLOW_COLOR}${text}${RESET_COLOR}`);
|
||||||
console.log(` ${i + 1}) ${YELLOW_COLOR}${warning}${RESET_COLOR}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let clearExit = messages.length === 0;
|
const info = messages.filter((message) => message.type === 'info');
|
||||||
if (changedFiles) {
|
if (info.length) {
|
||||||
if (clearExit)
|
console.log('DocLint Info:');
|
||||||
console.log(`${YELLOW_COLOR}Some files were updated.${RESET_COLOR}`);
|
for (let i = 0; i < info.length; i++) {
|
||||||
clearExit = false;
|
const text = info[i].text.split('\n').join('\n ');
|
||||||
|
console.log(` ${i + 1}) ${BLUE_COLOR}${text}${RESET_COLOR}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changedFiles) {
|
||||||
|
console.log(`${BLUE_COLOR}Some files were updated.${RESET_COLOR}`);
|
||||||
}
|
}
|
||||||
console.log(`${errors.length} failures, ${warnings.length} warnings.`);
|
|
||||||
|
|
||||||
if (!clearExit && !process.env.GITHUB_ACTIONS)
|
console.log(
|
||||||
|
`${info.length} info, ${errors.length} failures, ${warnings.length} warnings.`
|
||||||
|
);
|
||||||
|
|
||||||
|
const clearExit = errors.length + warnings.length === 0;
|
||||||
|
if (!clearExit && !process.env.GITHUB_ACTIONS) {
|
||||||
console.log(
|
console.log(
|
||||||
'\nIs your lib/ directory up to date? You might need to `npm run tsc`.\n'
|
'\nIs your lib/ directory up to date? You might need to `npm run tsc`.\n'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const runningTime = Date.now() - startTime;
|
const runningTime = Date.now() - startTime;
|
||||||
console.log(`DocLint Finished in ${runningTime / 1000} seconds`);
|
console.log(`DocLint Finished in ${runningTime / 1000} seconds`);
|
||||||
|
@ -31,7 +31,7 @@ module.exports.ensureReleasedAPILinks = function (sources, version) {
|
|||||||
const text = source.text();
|
const text = source.text();
|
||||||
const newText = text.replace(apiLinkRegex, lastReleasedAPI);
|
const newText = text.replace(apiLinkRegex, lastReleasedAPI);
|
||||||
if (source.setText(newText))
|
if (source.setText(newText))
|
||||||
messages.push(Message.warning(`GEN: updated ${source.projectPath()}`));
|
messages.push(Message.info(`GEN: updated ${source.projectPath()}`));
|
||||||
}
|
}
|
||||||
return messages;
|
return messages;
|
||||||
};
|
};
|
||||||
@ -87,7 +87,7 @@ module.exports.runCommands = function (sources, version) {
|
|||||||
else if (applyCommand(command, newText)) changedSources.add(command.source);
|
else if (applyCommand(command, newText)) changedSources.add(command.source);
|
||||||
}
|
}
|
||||||
for (const source of changedSources)
|
for (const source of changedSources)
|
||||||
messages.push(Message.warning(`GEN: updated ${source.projectPath()}`));
|
messages.push(Message.info(`GEN: updated ${source.projectPath()}`));
|
||||||
return messages;
|
return messages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user