@@ -6,7 +6,7 @@ import esbuild from "esbuild";
6
6
import { task } from "hereby" ;
7
7
import _glob from "glob" ;
8
8
import util from "util" ;
9
- import { exec , readJson , needsUpdate , getDiffTool , getDirSize } from "./scripts/build/utils.mjs" ;
9
+ import { exec , readJson , getDiffTool , getDirSize } from "./scripts/build/utils.mjs" ;
10
10
import { runConsoleTests , refBaseline , localBaseline , refRwcBaseline , localRwcBaseline } from "./scripts/build/tests.mjs" ;
11
11
import { buildProject as realBuildProject , cleanProject } from "./scripts/build/projects.mjs" ;
12
12
import { localizationDirectories } from "./scripts/build/localization.mjs" ;
@@ -84,23 +84,19 @@ export const generateLibs = task({
84
84
description : "Builds the library targets" ,
85
85
run : async ( ) => {
86
86
await fs . promises . mkdir ( "./built/local" , { recursive : true } ) ;
87
- const allSources = libs . flatMap ( ( lib ) => lib . sources ) ;
88
- const allTargets = libs . flatMap ( ( lib ) => lib . target ) ;
89
- if ( needsUpdate ( [ copyright , ...allSources ] , allTargets ) ) {
90
- for ( const lib of libs ) {
91
- let output = getCopyrightHeader ( ) ;
92
-
93
- await fs . promises . writeFile ( lib . target , getCopyrightHeader ( ) ) ;
94
- for ( const source of lib . sources ) {
95
- const contents = await fs . promises . readFile ( source , "utf-8" ) ;
96
- // TODO(jakebailey): "\n\n" is for compatibility with our current tests; our test baselines
97
- // are sensitive to the positions of things in the lib files. Eventually remove this,
98
- // or remove lib.d.ts line numbers from our baselines.
99
- output += "\n\n" + contents . replace ( / \r \n / g, "\n" ) ;
100
- }
101
-
102
- await fs . promises . writeFile ( lib . target , output ) ;
87
+ for ( const lib of libs ) {
88
+ let output = getCopyrightHeader ( ) ;
89
+
90
+ await fs . promises . writeFile ( lib . target , getCopyrightHeader ( ) ) ;
91
+ for ( const source of lib . sources ) {
92
+ const contents = await fs . promises . readFile ( source , "utf-8" ) ;
93
+ // TODO(jakebailey): "\n\n" is for compatibility with our current tests; our test baselines
94
+ // are sensitive to the positions of things in the lib files. Eventually remove this,
95
+ // or remove lib.d.ts line numbers from our baselines.
96
+ output += "\n\n" + contents . replace ( / \r \n / g, "\n" ) ;
103
97
}
98
+
99
+ await fs . promises . writeFile ( lib . target , output ) ;
104
100
}
105
101
} ,
106
102
} ) ;
@@ -121,9 +117,7 @@ export const generateDiagnostics = task({
121
117
name : "generate-diagnostics" ,
122
118
description : "Generates a diagnostic file in TypeScript based on an input JSON file" ,
123
119
run : async ( ) => {
124
- if ( needsUpdate ( diagnosticMessagesJson , [ diagnosticMessagesGeneratedJson , diagnosticInformationMapTs ] ) ) {
125
- await exec ( process . execPath , [ "scripts/processDiagnosticMessages.mjs" , diagnosticMessagesJson ] ) ;
126
- }
120
+ await exec ( process . execPath , [ "scripts/processDiagnosticMessages.mjs" , diagnosticMessagesJson ] ) ;
127
121
}
128
122
} ) ;
129
123
@@ -154,13 +148,10 @@ const localizationTargets = localizationDirectories
154
148
. map ( f => `built/local/${ f } /diagnosticMessages.generated.json` )
155
149
. concat ( generatedLCGFile ) ;
156
150
157
- const localize = task ( {
151
+ export const localize = task ( {
158
152
name : "localize" ,
159
- run : async ( ) => {
160
- if ( needsUpdate ( diagnosticMessagesGeneratedJson , generatedLCGFile ) ) {
161
- return exec ( process . execPath , [ "scripts/generateLocalizedDiagnosticMessages.mjs" , "src/loc/lcl" , "built/local" , diagnosticMessagesGeneratedJson ] , { ignoreExitCode : true } ) ;
162
- }
163
- }
153
+ dependencies : [ generateDiagnostics ] ,
154
+ run : ( ) => exec ( process . execPath , [ "scripts/generateLocalizedDiagnosticMessages.mjs" , "src/loc/lcl" , "built/local" , diagnosticMessagesGeneratedJson ] , { ignoreExitCode : true } ) ,
164
155
} ) ;
165
156
166
157
export const buildSrc = task ( {
@@ -533,11 +524,9 @@ export const generateTypesMap = task({
533
524
run : async ( ) => {
534
525
const source = "src/server/typesMap.json" ;
535
526
const target = "built/local/typesMap.json" ;
536
- if ( needsUpdate ( source , target ) ) {
537
- const contents = await fs . promises . readFile ( source , "utf-8" ) ;
538
- JSON . parse ( contents ) ;
539
- await fs . promises . writeFile ( target , contents ) ;
540
- }
527
+ const contents = await fs . promises . readFile ( source , "utf-8" ) ;
528
+ JSON . parse ( contents ) ; // Validates that the JSON parses.
529
+ await fs . promises . writeFile ( target , contents ) ;
541
530
}
542
531
} ) ;
543
532
@@ -552,15 +541,13 @@ cleanTasks.push(cleanTypesMap);
552
541
// it to be synced to the Azure DevOps repo, so that it can get picked up by the build
553
542
// pipeline that generates the localization artifacts that are then fed into the translation process.
554
543
const builtLocalDiagnosticMessagesGeneratedJson = "built/local/diagnosticMessages.generated.json" ;
555
- const copyBuiltLocalDiagnosticMessages = task ( {
544
+ export const copyBuiltLocalDiagnosticMessages = task ( {
556
545
name : "copy-built-local-diagnostic-messages" ,
557
546
dependencies : [ generateDiagnostics ] ,
558
547
run : async ( ) => {
559
- if ( needsUpdate ( diagnosticMessagesGeneratedJson , builtLocalDiagnosticMessagesGeneratedJson ) ) {
560
- const contents = await fs . promises . readFile ( diagnosticMessagesGeneratedJson , "utf-8" ) ;
561
- JSON . parse ( contents ) ;
562
- await fs . promises . writeFile ( builtLocalDiagnosticMessagesGeneratedJson , contents ) ;
563
- }
548
+ const contents = await fs . promises . readFile ( diagnosticMessagesGeneratedJson , "utf-8" ) ;
549
+ JSON . parse ( contents ) ; // Validates that the JSON parses.
550
+ await fs . promises . writeFile ( builtLocalDiagnosticMessagesGeneratedJson , contents ) ;
564
551
}
565
552
} ) ;
566
553
0 commit comments