Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛑yarn prepare errors in the logs #6415

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/compile-js.js
Original file line number Diff line number Diff line change
@@ -22,10 +22,10 @@ function getCommand(watch) {
return `${babel} ${args.join(' ')}`;
}

function handleExit(code, errorCallback) {
function handleExit(code, stderr, errorCallback) {
if (code !== 0) {
if (errorCallback && typeof errorCallback === 'function') {
errorCallback();
errorCallback(stderr);
}

shell.exit(code);
@@ -43,9 +43,10 @@ function babelify(options = {}) {
}

const command = getCommand(watch);
const { code } = shell.exec(command, { silent });

handleExit(code, errorCallback);
const { code, stderr } = shell.exec(command, { silent });

handleExit(code, stderr, errorCallback);
}

module.exports = {
8 changes: 4 additions & 4 deletions scripts/compile-ts.js
Original file line number Diff line number Diff line change
@@ -15,10 +15,10 @@ function getCommand(watch) {
return `${tsc} ${args.join(' ')}`;
}

function handleExit(code, errorCallback) {
function handleExit(code, stderr, errorCallback) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one will be gone after the @babel/preset-typescript migration.

if (code !== 0) {
if (errorCallback && typeof errorCallback === 'function') {
errorCallback();
errorCallback(stderr);
}

shell.exit(code);
@@ -47,9 +47,9 @@ function tscfy(options = {}) {
}

const command = getCommand(watch);
const { code } = shell.exec(command, { silent });
const { code, stderr } = shell.exec(command, { silent });

handleExit(code, errorCallback);
handleExit(code, stderr, errorCallback);
}

module.exports = {
9 changes: 5 additions & 4 deletions scripts/prepare.js
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ function removeTsFromDist() {
}
}

function logError(type, packageJson) {
function logError(type, packageJson, errorLogs) {
log.error(`FAILED (${type}) : ${errorLogs}`);
log.error(
`FAILED to compile ${type}: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`
);
@@ -39,11 +40,11 @@ const packageJson = getPackageJson();

removeDist();
if (packageJson && packageJson.types && packageJson.types.indexOf('d.ts') !== -1) {
tscfy({ errorCallback: () => logError('ts', packageJson) });
tscfy({ errorCallback: errorLogs => logError('ts', packageJson, errorLogs) });
} else {
babelify({ errorCallback: () => logError('js', packageJson) });
babelify({ errorCallback: errorLogs => logError('js', packageJson, errorLogs) });
removeTsFromDist();
tscfy({ errorCallback: () => logError('ts', packageJson) });
tscfy({ errorCallback: errorLogs => logError('ts', packageJson, errorLogs) });
}

console.log(chalk.gray(`Built: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`));