@@ -106,7 +106,7 @@ function ace() {
106
106
107
107
console . log ( '# ace ---------' ) ;
108
108
for ( var i = 0 ; i < 4 ; i ++ )
109
- buildAce ( { compress : i & 2 , noconflict : i & 1 } ) ;
109
+ buildAce ( { compress : i & 2 , noconflict : i & 1 , check : true } ) ;
110
110
}
111
111
112
112
function demo ( ) {
@@ -261,11 +261,7 @@ function buildAceModuleInternal(opts, callback) {
261
261
code = result . codeMin ;
262
262
}
263
263
264
- var targetDir = BUILD_DIR + "/src" ;
265
- if ( opts . compress )
266
- targetDir += "-min" ;
267
- if ( opts . noconflict )
268
- targetDir += "-noconflict" ;
264
+ var targetDir = getTargetDir ( opts ) ;
269
265
270
266
var to = / ^ ( [ \\ / ] | \w : ) / . test ( opts . outputFile )
271
267
? opts . outputFile
@@ -341,13 +337,13 @@ function buildAce(options) {
341
337
var snippetFiles = jsFileList ( "lib/ace/snippets" ) ;
342
338
var modeNames = modeList ( ) ;
343
339
344
- buildCore ( options , { outputFile : "ace.js" } ) ,
340
+ buildCore ( options , { outputFile : "ace.js" } , addCb ( ) ) ,
345
341
// modes
346
342
modeNames . forEach ( function ( name ) {
347
343
buildSubmodule ( options , {
348
344
projectType : "mode" ,
349
345
require : [ "ace/mode/" + name ]
350
- } , "mode-" + name ) ;
346
+ } , "mode-" + name , addCb ( ) ) ;
351
347
} ) ;
352
348
// snippets
353
349
modeNames . forEach ( function ( name ) {
@@ -356,28 +352,28 @@ function buildAce(options) {
356
352
357
353
buildSubmodule ( options , {
358
354
require : [ "ace/snippets/" + name ] ,
359
- } , "snippets/" + name ) ;
355
+ } , "snippets/" + name , addCb ( ) ) ;
360
356
} ) ;
361
357
// themes
362
358
jsFileList ( "lib/ace/theme" ) . forEach ( function ( name ) {
363
359
buildSubmodule ( options , {
364
360
projectType : "theme" ,
365
361
require : [ "ace/theme/" + name ]
366
- } , "theme-" + name ) ;
362
+ } , "theme-" + name , addCb ( ) ) ;
367
363
} ) ;
368
364
// keybindings
369
365
[ "vim" , "emacs" ] . forEach ( function ( name ) {
370
366
buildSubmodule ( options , {
371
367
projectType : "keybinding" ,
372
368
require : [ "ace/keyboard/" + name ]
373
- } , "keybinding-" + name ) ;
369
+ } , "keybinding-" + name , addCb ( ) ) ;
374
370
} ) ;
375
371
// extensions
376
372
jsFileList ( "lib/ace/ext" ) . forEach ( function ( name ) {
377
373
buildSubmodule ( options , {
378
374
projectType : "ext" ,
379
375
require : [ "ace/ext/" + name ]
380
- } , "ext-" + name ) ;
376
+ } , "ext-" + name , addCb ( ) ) ;
381
377
} ) ;
382
378
// workers
383
379
workers ( "lib/ace/mode" ) . forEach ( function ( name ) {
@@ -390,8 +386,20 @@ function buildAce(options) {
390
386
transforms : [ ] ,
391
387
order : - 1000
392
388
} ] ,
393
- } , "worker-" + name ) ;
389
+ } , "worker-" + name , addCb ( ) ) ;
394
390
} ) ;
391
+ //
392
+ function addCb ( ) {
393
+ addCb . count = ( addCb . count || 0 ) + 1 ;
394
+ return done
395
+ }
396
+ function done ( ) {
397
+ if ( -- addCb . count > 0 )
398
+ return ;
399
+ if ( options . check )
400
+ sanityCheck ( options )
401
+ console . log ( "Finished building " + getTargetDir ( options ) )
402
+ }
395
403
}
396
404
397
405
function getLoadedFileList ( options , callback , result ) {
@@ -476,7 +484,7 @@ function namespace(ns) {
476
484
. toString ( )
477
485
. replace ( / A C E _ N A M E S P A C E \s * = \s * " " / , 'ACE_NAMESPACE = "' + ns + '"' )
478
486
. replace ( / \b d e f i n e \( / g, function ( def , index , source ) {
479
- if ( / ( ^ | [ ; } ) ] ) \s * $ / . test ( source . slice ( 0 , index ) ) )
487
+ if ( / ( ^ | [ ; } ) , ] ) \s * $ / . test ( source . slice ( 0 , index ) ) )
480
488
return ns + "." + def ;
481
489
return def ;
482
490
} ) ;
@@ -571,6 +579,35 @@ function extend(base, extra) {
571
579
return base ;
572
580
}
573
581
582
+ function getTargetDir ( opts ) {
583
+ var targetDir = BUILD_DIR + "/src" ;
584
+ if ( opts . compress )
585
+ targetDir += "-min" ;
586
+ if ( opts . noconflict )
587
+ targetDir += "-noconflict" ;
588
+ return targetDir ;
589
+ }
590
+
591
+ function sanityCheck ( opts ) {
592
+ var targetDir = getTargetDir ( opts ) ;
593
+ require ( "child_process" ) . execFile ( process . execPath , [ "-e" , "(" + function ( ) {
594
+ window = global ;
595
+ require ( "./ace" ) ;
596
+ if ( typeof ace . edit != "function" )
597
+ process . exit ( 1 ) ;
598
+ require ( "fs" ) . readdirSync ( "." ) . forEach ( function ( p ) {
599
+ if ( ! / a c e \. j s $ / . test ( p ) && / \. j s $ / . test ( p ) )
600
+ require ( "./" + p ) ;
601
+ } ) ;
602
+ process . exit ( 0 ) ;
603
+ } + ")()" ] , {
604
+ cwd : targetDir
605
+ } , function ( err , stdout ) {
606
+ if ( err )
607
+ throw err ;
608
+ } ) ;
609
+ }
610
+
574
611
if ( ! module . parent )
575
612
main ( process . argv ) ;
576
613
else
0 commit comments