11#!/usr/bin/env node
22import fs from "node:fs/promises" ;
3- import path from "node:path" ;
43import os from "node:os" ;
4+ import path from "node:path" ;
55import { fileURLToPath } from "node:url" ;
66import { Worker , isMainThread , parentPort } from "worker_threads" ;
77
@@ -12,30 +12,30 @@ import type {
1212 MercuryBundleReset
1313} from "../types" ;
1414
15- import {
16- ensureDirectoryExistsAndItsClear ,
17- getFilesInDir ,
18- refreshAngularBrowser
19- // copyDirectories
20- } from "./internal/file-management.js" ;
2115import {
2216 BASE_BUNDLES_OUT_DIR ,
2317 CSS_BUNDLES_OUT_DIR ,
2418 SCSS_BUNDLES_INPUT_DIR
2519 // SCSS_BUNDLES_OUT_DIR
2620} from "./internal/constants.js" ;
21+ import {
22+ ensureDirectoryExistsAndItsClear ,
23+ getFilesInDir ,
24+ refreshAngularBrowser
25+ // copyDirectories
26+ } from "./internal/file-management.js" ;
2727import { transpileCssBundleWithPlaceholder } from "./internal/transpile-bundle-and-create-mappings.js" ;
2828import { measureTime } from "./internal/utils.js" ;
2929
30- import type { CLIArguments , FileMetadata } from "./internal/types " ;
30+ import { createBundlesWithCustomPaths } from "./internal/create-bundles-with-custom-paths.js " ;
3131import { printBundleWasTranspiled } from "./internal/print-utils.js" ;
32+ import type { CLIArguments , FileMetadata } from "./internal/types" ;
33+ import { getArguments } from "./internal/validate-args.js" ;
3234import {
3335 printRebuilding ,
3436 stopRebuildingStdout ,
3537 watchFileSystemChanges
3638} from "./internal/watch-fs.js" ;
37- import { getArguments } from "./internal/validate-args.js" ;
38- import { createBundlesWithCustomPaths } from "./internal/create-bundles-with-custom-paths.js" ;
3939
4040type BundleToAvoidRebuild =
4141 | MercuryBundleBase
@@ -52,10 +52,11 @@ const MESSAGE_TYPE = {
5252if ( isMainThread ) {
5353 const [ , , ...args ] = process . argv ;
5454 const watchMode = args . find ( arg => arg === "--watch" ) ;
55+ const ciMode = args . find ( arg => arg === "--ci" ) ;
5556 let cliArgs : CLIArguments | undefined ;
5657
5758 // Check if the bundles processing is running in watch mode
58- if ( watchMode ) {
59+ if ( watchMode || ciMode ) {
5960 cliArgs = getArguments ( ) ;
6061
6162 if ( ! cliArgs ) {
@@ -191,7 +192,7 @@ if (isMainThread) {
191192 return ;
192193 }
193194
194- if ( ! watchMode ) {
195+ if ( ! watchMode && ! ciMode ) {
195196 printBundleWasTranspiled ( fileMetadata . filePath ) ;
196197 }
197198
@@ -261,6 +262,9 @@ if (isMainThread) {
261262 measureTime ( compileAndCreateBundles ) . finally ( ( ) =>
262263 watchFileSystemChanges ( compileAndCreateBundles )
263264 ) ;
265+ } else if ( ciMode ) {
266+ await compileAndCreateBundles ( ) ;
267+ process . exit ( ) ;
264268 }
265269 // There is no need to wait for any changes, since the watch mode is not enabled
266270 else {
0 commit comments