|
@@ -1,5 +1,6 @@
|
|
|
import process from 'node:process';
|
|
import process from 'node:process';
|
|
|
import os from 'node:os';
|
|
import os from 'node:os';
|
|
|
|
|
+import fs from 'node:fs';
|
|
|
|
|
|
|
|
import { downloadPreviousBuild } from './download-previous-build';
|
|
import { downloadPreviousBuild } from './download-previous-build';
|
|
|
import { buildCommon } from './build-common';
|
|
import { buildCommon } from './build-common';
|
|
@@ -28,6 +29,7 @@ import { buildCloudMounterRules } from './build-cloudmounter-rules';
|
|
|
import { createSpan, printTraceResult, whyIsNodeRunning } from './trace';
|
|
import { createSpan, printTraceResult, whyIsNodeRunning } from './trace';
|
|
|
import { buildDeprecateFiles } from './build-deprecate-files';
|
|
import { buildDeprecateFiles } from './build-deprecate-files';
|
|
|
import { cacheGc } from './lib/make-fetch-happen';
|
|
import { cacheGc } from './lib/make-fetch-happen';
|
|
|
|
|
+import path from 'node:path';
|
|
|
|
|
|
|
|
process.on('uncaughtException', (error) => {
|
|
process.on('uncaughtException', (error) => {
|
|
|
console.error('Uncaught exception:', error);
|
|
console.error('Uncaught exception:', error);
|
|
@@ -38,6 +40,8 @@ process.on('unhandledRejection', (reason) => {
|
|
|
process.exit(1);
|
|
process.exit(1);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+const buildFinishedLock = path.join(__dirname, '../.BUILD_FINISHED');
|
|
|
|
|
+
|
|
|
(async () => {
|
|
(async () => {
|
|
|
console.log('Version:', process.version);
|
|
console.log('Version:', process.version);
|
|
|
|
|
|
|
@@ -60,6 +64,10 @@ process.on('unhandledRejection', (reason) => {
|
|
|
|
|
|
|
|
const rootSpan = createSpan('root');
|
|
const rootSpan = createSpan('root');
|
|
|
|
|
|
|
|
|
|
+ if (fs.existsSync(buildFinishedLock)) {
|
|
|
|
|
+ fs.unlinkSync(buildFinishedLock);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
const downloadPreviousBuildPromise = downloadPreviousBuild(rootSpan);
|
|
const downloadPreviousBuildPromise = downloadPreviousBuild(rootSpan);
|
|
|
const buildCommonPromise = downloadPreviousBuildPromise.then(() => buildCommon(rootSpan));
|
|
const buildCommonPromise = downloadPreviousBuildPromise.then(() => buildCommon(rootSpan));
|
|
@@ -97,6 +105,9 @@ process.on('unhandledRejection', (reason) => {
|
|
|
|
|
|
|
|
printTraceResult(rootSpan.traceResult);
|
|
printTraceResult(rootSpan.traceResult);
|
|
|
|
|
|
|
|
|
|
+ // write a file to demonstrate that the build is finished
|
|
|
|
|
+ fs.writeFileSync(buildFinishedLock, 'BUILD_FINISHED\n');
|
|
|
|
|
+
|
|
|
// Finish the build to avoid leaking timer/fetch ref
|
|
// Finish the build to avoid leaking timer/fetch ref
|
|
|
await whyIsNodeRunning();
|
|
await whyIsNodeRunning();
|
|
|
process.exit(0);
|
|
process.exit(0);
|