1
0

amberc.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /**
  2. * This is a "compiler" for Amber code.
  3. * Put the following code into compiler.js:
  4. * var amberc = require('amberc');
  5. * var compiler = new amberc.Compiler('path/to/amber', ['/optional/path/to/compiler.jar]);
  6. * compiler.main();
  7. *
  8. * Execute 'node compiler.js' without arguments or with -h / --help for help.
  9. */
  10. /**
  11. * Map the async filter function onto array and evaluate callback, once all have finished.
  12. * Taken from: http://howtonode.org/control-flow-part-iii
  13. */
  14. function async_map(array, filter, callback) {
  15. if (0 === array.length) {
  16. callback(null, null);
  17. return;
  18. }
  19. var counter = array.length;
  20. var new_array = [];
  21. array.forEach(function (item, index) {
  22. filter(item, function (err, result) {
  23. if (err) { callback(err); return; }
  24. new_array[index] = result;
  25. counter--;
  26. if (counter === 0) {
  27. callback(null, new_array);
  28. }
  29. });
  30. });
  31. }
  32. /**
  33. * Always evaluates the callback parameter.
  34. * Used by Combo blocks to always call the next function,
  35. * even if all of the other functions did not run.
  36. */
  37. function always_resolve(callback) {
  38. callback();
  39. }
  40. /**
  41. * Helper for concatenating Amber generated AMD modules.
  42. * The produced output can be exported and run as an independent program.
  43. *
  44. * var concatenator = createConcatenator();
  45. * concatenator.start(); // write the required AMD define header
  46. * concatenator.add(module1);
  47. * concatenator.addId(module1_ID);
  48. * //...
  49. * concatenator.finish("//some last code");
  50. * var concatenation = concatenator.toString();
  51. * // The variable concatenation contains the concatenated result
  52. * // which can either be stored in a file or interpreted with eval().
  53. */
  54. function createConcatenator () {
  55. return {
  56. elements: [],
  57. ids: [],
  58. add: function () {
  59. this.elements.push.apply(this.elements, arguments);
  60. },
  61. addId: function () {
  62. this.ids.push.apply(this.ids, arguments);
  63. },
  64. forEach: function () {
  65. this.elements.forEach.apply(this.elements, arguments);
  66. },
  67. start: function () {
  68. this.add(
  69. 'var define = (' + require('amdefine') + ')(), requirejs = define.require;',
  70. 'define("amber_vm/browser-compatibility", [], {});'
  71. );
  72. },
  73. finish: function (realWork) {
  74. this.add(
  75. 'define("amber_vm/_init", ["amber_vm/smalltalk","' + this.ids.join('","') + '"], function (smalltalk) {',
  76. 'smalltalk.initialize();',
  77. realWork,
  78. '});',
  79. 'requirejs("amber_vm/_init");'
  80. );
  81. },
  82. toString: function () {
  83. return this.elements.join('\n');
  84. }
  85. };
  86. }
  87. /**
  88. * Combine several async functions and evaluate callback once all of them have finished.
  89. * Taken from: http://howtonode.org/control-flow
  90. */
  91. function Combo(callback) {
  92. this.callback = callback;
  93. this.items = 0;
  94. this.results = [];
  95. }
  96. Combo.prototype = {
  97. add: function () {
  98. var self = this,
  99. id = this.items;
  100. this.items++;
  101. return function () {
  102. self.check(id, arguments);
  103. };
  104. },
  105. check: function (id, arguments) {
  106. this.results[id] = Array.prototype.slice.call(arguments);
  107. this.items--;
  108. if (this.items == 0) {
  109. this.callback.apply(this, this.results);
  110. }
  111. }
  112. };
  113. var path = require('path'),
  114. util = require('util'),
  115. fs = require('fs'),
  116. exec = require('child_process').exec;
  117. /**
  118. * AmberC constructor function.
  119. * amber_dir: points to the location of an amber installation
  120. * closure_jar: location of compiler.jar (can be left undefined)
  121. */
  122. function AmberC(amber_dir, closure_jar) {
  123. this.amber_dir = amber_dir;
  124. this.closure_jar = closure_jar || '';
  125. this.kernel_libraries = ['@boot', '@smalltalk', '@nil', '@_st', 'Kernel-Objects', 'Kernel-Classes', 'Kernel-Methods',
  126. 'Kernel-Collections', 'Kernel-Infrastructure', 'Kernel-Exceptions', 'Kernel-Transcript',
  127. 'Kernel-Announcements'];
  128. this.compiler_libraries = this.kernel_libraries.concat(['@parser', 'Importer-Exporter', 'Compiler-Exceptions',
  129. 'Compiler-Core', 'Compiler-AST', 'Compiler-Exceptions', 'Compiler-IR', 'Compiler-Inlining', 'Compiler-Semantic']);
  130. }
  131. /**
  132. * Default values.
  133. */
  134. var createDefaults = function(amber_dir, finished_callback){
  135. if (undefined === amber_dir) {
  136. throw new Error('createDefaults() function needs a valid amber_dir parameter');
  137. }
  138. return {
  139. 'load': [],
  140. 'main': undefined,
  141. 'mainfile': undefined,
  142. 'stFiles': [],
  143. 'jsFiles': [],
  144. 'jsGlobals': [],
  145. 'amd_namespace': 'amber_core',
  146. 'closure': false,
  147. 'closure_full': false,
  148. 'closure_options': ' --language_in=ECMASCRIPT5 ',
  149. 'suffix': '',
  150. 'loadsuffix': '',
  151. 'suffix_used': '',
  152. 'libraries': [],
  153. 'compile': [],
  154. 'compiled': [],
  155. 'program': undefined,
  156. 'output_dir': undefined,
  157. 'verbose': false,
  158. 'finished_callback': finished_callback
  159. };
  160. };
  161. /**
  162. * Main function for executing the compiler.
  163. * If check_configuration_ok() returns successfully the configuration is set on the current compiler
  164. * instance and check_for_closure_compiler() gets called.
  165. * The last step is to call collect_files().
  166. */
  167. AmberC.prototype.main = function(configuration, finished_callback) {
  168. console.time('Compile Time');
  169. if (undefined !== finished_callback) {
  170. configuration.finished_callback = finished_callback;
  171. }
  172. if (configuration.amd_namespace.length == 0) {
  173. configuration.amd_namespace = 'amber_core';
  174. }
  175. console.ambercLog = console.log;
  176. if (false === configuration.verbose) {
  177. console.log = function() {};
  178. }
  179. if (this.check_configuration_ok(configuration)) {
  180. this.defaults = configuration;
  181. this.defaults.smalltalk = {}; // the evaluated compiler will be stored in this variable (see create_compiler)
  182. var self = this;
  183. this.check_for_closure_compiler(function(){
  184. self.collect_files(self.defaults.stFiles, self.defaults.jsFiles)
  185. });
  186. }
  187. };
  188. /**
  189. * Check if the passed in configuration object has sufficient/nonconflicting values
  190. */
  191. AmberC.prototype.check_configuration_ok = function(configuration) {
  192. if (undefined === configuration) {
  193. throw new Error('AmberC.check_configuration_ok(): missing configuration object');
  194. }
  195. if (0 === configuration.jsFiles.length && 0 === configuration.stFiles.lenght) {
  196. throw new Error('AmberC.check_configuration_ok(): no files to compile/link specified in configuration object');
  197. }
  198. return true;
  199. };
  200. /**
  201. * Checks if the java executable exists and afterwards,
  202. * if compiler.jar exists at the path stored in this.closure_jar.
  203. * All closure related entries are set to false upon failure.
  204. *
  205. * callback gets called in any case.
  206. */
  207. AmberC.prototype.check_for_closure_compiler = function(callback) {
  208. var defaults = this.defaults;
  209. var self = this;
  210. if (defaults.closure) {
  211. exec('which java', function(error, stdout, stderr) {
  212. // stdout contains path to java executable
  213. if (null !== error) {
  214. console.warn('java is not installed but is needed for running the Closure compiler (-O, -A or -o flags).');
  215. defaults.closure = false;
  216. defaults.closure_full = false;
  217. callback();
  218. return;
  219. }
  220. fs.exists(self.closure_jar, function(exists) {
  221. if (!exists) {
  222. console.warn('Can not find Closure compiler at: ' + self.closure_jar);
  223. defaults.closure = false;
  224. defaults.closure_full = false;
  225. } else {
  226. console.warn('Closure compiler found at: ' + self.closure_jar);
  227. }
  228. callback();
  229. return;
  230. });
  231. });
  232. } else {
  233. callback();
  234. }
  235. };
  236. /**
  237. * Check if the file given as parameter exists in the local directory or in $AMBER/js/.
  238. * '.js' is appended first.
  239. *
  240. * @param filename name of a file without '.js' prefix
  241. * @param callback gets called on success with path to .js file as parameter
  242. */
  243. AmberC.prototype.resolve_js = function(filename, callback) {
  244. var special = filename[0] == "@";
  245. if (special) {
  246. filename = filename.slice(1);
  247. }
  248. var baseName = path.basename(filename, '.js');
  249. var jsFile = baseName + this.defaults.loadsuffix + '.js';
  250. var amberJsFile = path.join(this.amber_dir, special?'support':'js', jsFile);
  251. console.log('Resolving: ' + jsFile);
  252. fs.exists(jsFile, function(exists) {
  253. if (exists) {
  254. callback(jsFile);
  255. } else {
  256. fs.exists(amberJsFile, function(exists) {
  257. if (exists) {
  258. callback(amberJsFile);
  259. } else {
  260. throw(new Error('JavaScript file not found: ' + jsFile));
  261. }
  262. });
  263. }
  264. });
  265. };
  266. /**
  267. * Collect libraries and Smalltalk files looking
  268. * both locally and in $AMBER/js and $AMBER/st.
  269. * Followed by resolve_libraries().
  270. */
  271. AmberC.prototype.collect_files = function(stFiles, jsFiles) {
  272. var self = this;
  273. var collected_files = new Combo(function() {
  274. self.resolve_libraries();
  275. });
  276. if (0 !== stFiles.length) {
  277. self.collect_st_files(stFiles, collected_files.add());
  278. }
  279. if (0 !== jsFiles.length) {
  280. self.collect_js_files(jsFiles, collected_files.add());
  281. }
  282. };
  283. /**
  284. * Resolve st files given by stFiles and add them to defaults.compile.
  285. * Respective categories get added to defaults.compile_categories.
  286. * callback is evaluated afterwards.
  287. */
  288. AmberC.prototype.collect_st_files = function(stFiles, callback) {
  289. var defaults = this.defaults;
  290. var self = this;
  291. var collected_st_files = new Combo(function() {
  292. Array.prototype.slice.call(arguments).forEach(function(data) {
  293. var stFile = data[0];
  294. defaults.compile.push(stFile);
  295. });
  296. callback();
  297. });
  298. stFiles.forEach(function(stFile) {
  299. var _callback = collected_st_files.add();
  300. console.log('Checking: ' + stFile);
  301. var amberStFile = path.join(self.amber_dir, 'st', stFile);
  302. fs.exists(stFile, function(exists) {
  303. if (exists) {
  304. _callback(stFile);
  305. } else {
  306. console.log('Checking: ' + amberStFile);
  307. fs.exists(amberStFile, function(exists) {
  308. if (exists) {
  309. _callback(amberStFile);
  310. } else {
  311. throw(new Error('Smalltalk file not found: ' + amberStFile));
  312. }
  313. });
  314. }
  315. });
  316. });
  317. };
  318. /**
  319. * Resolve js files given by jsFiles and add them to defaults.libraries.
  320. * callback is evaluated afterwards.
  321. */
  322. AmberC.prototype.collect_js_files = function(jsFiles, callback) {
  323. var self = this;
  324. var collected_js_files = new Combo(function() {
  325. Array.prototype.slice.call(arguments).forEach(function(file) {
  326. self.defaults.libraries.push(file[0]);
  327. });
  328. callback();
  329. });
  330. jsFiles.forEach(function(jsFile) {
  331. self.resolve_js(jsFile, collected_js_files.add());
  332. });
  333. };
  334. /**
  335. * Resolve kernel and compiler files.
  336. * Followed by resolve_init().
  337. */
  338. AmberC.prototype.resolve_libraries = function() {
  339. // Resolve libraries listed in this.kernel_libraries
  340. var self = this;
  341. var all_resolved = new Combo(function(resolved_kernel_files, resolved_compiler_files) {
  342. self.create_compiler(resolved_compiler_files[0]);
  343. });
  344. this.resolve_kernel(all_resolved.add());
  345. this.resolve_compiler(all_resolved.add());
  346. };
  347. /**
  348. * Resolve .js files needed by kernel
  349. * callback is evaluated afterwards.
  350. */
  351. AmberC.prototype.resolve_kernel = function(callback) {
  352. var self = this;
  353. var kernel_files = this.kernel_libraries.concat(this.defaults.load);
  354. var kernel_resolved = new Combo(function() {
  355. var foundLibraries = [];
  356. Array.prototype.slice.call(arguments).forEach(function(file) {
  357. if (undefined !== file[0]) {
  358. foundLibraries.push(file[0]);
  359. }
  360. });
  361. // boot.js and Kernel files need to be used first
  362. // otherwise the global smalltalk object is undefined
  363. self.defaults.libraries = foundLibraries.concat(self.defaults.libraries);
  364. callback(null);
  365. });
  366. kernel_files.forEach(function(file) {
  367. self.resolve_js(file, kernel_resolved.add());
  368. });
  369. always_resolve(kernel_resolved.add());
  370. };
  371. /**
  372. * Resolve .js files needed by compiler.
  373. * callback is evaluated afterwards with resolved files as argument.
  374. */
  375. AmberC.prototype.resolve_compiler = function(callback) {
  376. // Resolve compiler libraries
  377. var compiler_files = this.compiler_libraries.concat(this.defaults.load);
  378. var compiler_resolved = new Combo(function() {
  379. var compilerFiles = [];
  380. Array.prototype.slice.call(arguments).forEach(function(file) {
  381. if (undefined !== file[0]) {
  382. compilerFiles.push(file[0]);
  383. }
  384. });
  385. callback(compilerFiles);
  386. });
  387. var self = this
  388. compiler_files.forEach(function(file) {
  389. self.resolve_js(file, compiler_resolved.add());
  390. });
  391. always_resolve(compiler_resolved.add());
  392. };
  393. /**
  394. * Read all .js files needed by compiler and eval() them.
  395. * The finished Compiler gets stored in defaults.smalltalk.
  396. * Followed by compile().
  397. */
  398. AmberC.prototype.create_compiler = function(compilerFilesArray) {
  399. var self = this;
  400. var compiler_files = new Combo(function() {
  401. var builder = createConcatenator();
  402. builder.add('(function() {');
  403. builder.start();
  404. Array.prototype.slice.call(arguments).forEach(function(data) {
  405. // data is an array where index 0 is the error code and index 1 contains the data
  406. builder.add(data[1]);
  407. // matches and returns the "module_id" string in the AMD definition: define("module_id", ...)
  408. var match = ('' + data[1]).match(/^define\("([^"]*)"/);
  409. if (match) {
  410. builder.addId(match[1]);
  411. }
  412. });
  413. // store the generated smalltalk env in self.defaults.smalltalk
  414. builder.finish('self.defaults.smalltalk = smalltalk;');
  415. builder.add('})();');
  416. eval(builder.toString());
  417. console.log('Compiler loaded');
  418. self.defaults.smalltalk.ErrorHandler._setCurrent_(self.defaults.smalltalk.RethrowErrorHandler._new());
  419. if(0 != self.defaults.jsGlobals.length) {
  420. var jsGlobalVariables = self.defaults.smalltalk.globalJsVariables;
  421. jsGlobalVariables.push.apply(jsGlobalVariables, self.defaults.jsGlobals);
  422. }
  423. self.compile();
  424. });
  425. compilerFilesArray.forEach(function(file) {
  426. console.log('Loading file: ' + file);
  427. fs.readFile(file, compiler_files.add());
  428. });
  429. };
  430. /**
  431. * Compile all given .st files by importing them.
  432. * Followed by category_export().
  433. */
  434. AmberC.prototype.compile = function() {
  435. console.log('Compiling collected .st files')
  436. // import .st files
  437. var self = this;
  438. var imports = new Combo(function() {
  439. Array.prototype.slice.call(arguments).forEach(function(code) {
  440. if (undefined !== code[0]) {
  441. // get element 0 of code since all return values are stored inside an array by Combo
  442. self.defaults.smalltalk.Importer._new()._import_(code[0]._stream());
  443. }
  444. });
  445. self.category_export();
  446. });
  447. this.defaults.compile.forEach(function(stFile) {
  448. var callback = imports.add();
  449. if (/\.st/.test(stFile)) {
  450. console.ambercLog('Importing: ' + stFile);
  451. fs.readFile(stFile, 'utf8', function(err, data) {
  452. if (!err)
  453. callback(data);
  454. else
  455. throw new Error('Could not import: ' + stFile);
  456. });
  457. }
  458. });
  459. always_resolve(imports.add());
  460. };
  461. /**
  462. * Export compiled categories to JavaScript files.
  463. * Followed by verify().
  464. */
  465. AmberC.prototype.category_export = function() {
  466. var defaults = this.defaults;
  467. var self = this;
  468. // export categories as .js
  469. async_map(defaults.compile, function(stFile, callback) {
  470. var category = path.basename(stFile, '.st');
  471. var jsFilePath = defaults.output_dir;
  472. if (undefined === jsFilePath) {
  473. jsFilePath = path.dirname(stFile);
  474. }
  475. var jsFile = category + defaults.suffix_used + '.js';
  476. jsFile = path.join(jsFilePath, jsFile);
  477. defaults.compiled.push(jsFile);
  478. var smalltalk = defaults.smalltalk;
  479. var pluggableExporter = smalltalk.PluggableExporter;
  480. var packageObject = smalltalk.Package._named_(category);
  481. packageObject._transport()._namespace_(defaults.amd_namespace);
  482. fs.writeFile(jsFile, smalltalk.String._streamContents_(function (stream) {
  483. smalltalk.AmdExporter._new()._exportPackage_on_(packageObject, stream); }), function(err) {
  484. callback(null, null);
  485. });
  486. }, function(err, result){
  487. self.verify();
  488. });
  489. };
  490. /**
  491. * Verify if all .st files have been compiled.
  492. * Followed by compose_js_files() and optimize().
  493. */
  494. AmberC.prototype.verify = function() {
  495. console.log('Verifying if all .st files were compiled');
  496. var self = this;
  497. // copy array
  498. var compiledFiles = this.defaults.compiled.slice(0);
  499. async_map(compiledFiles,
  500. function(file, callback) {
  501. fs.exists(file, function(exists) {
  502. if (exists)
  503. callback(null, null);
  504. else
  505. throw(new Error('Compilation failed of: ' + file));
  506. });
  507. }, function(err, result) {
  508. self.compose_js_files();
  509. });
  510. };
  511. /**
  512. * Synchronous function.
  513. * Concatenates compiled JavaScript files into one file in the correct order.
  514. * The name of the produced file is given by defaults.program (set by the last commandline option).
  515. */
  516. AmberC.prototype.compose_js_files = function() {
  517. var defaults = this.defaults;
  518. var self = this;
  519. var programFile = defaults.program;
  520. if (undefined === programFile) {
  521. self.optimize();
  522. return;
  523. }
  524. if (undefined !== defaults.output_dir) {
  525. programFile = path.join(defaults.output_dir, programFile);
  526. }
  527. var program_files = [];
  528. if (0 !== defaults.libraries.length) {
  529. console.log('Collecting libraries: ' + defaults.libraries);
  530. program_files.push.apply(program_files, defaults.libraries);
  531. }
  532. if (0 !== defaults.compiled.length) {
  533. var compiledFiles = defaults.compiled.slice(0);
  534. console.log('Collecting compiled files: ' + compiledFiles);
  535. program_files.push.apply(program_files, compiledFiles);
  536. }
  537. console.ambercLog('Writing program file: %s.js', programFile);
  538. var fileStream = fs.createWriteStream(programFile + defaults.suffix_used + '.js');
  539. fileStream.on('error', function(error) {
  540. fileStream.end();
  541. console.ambercLog(error);
  542. });
  543. fileStream.on('close', function(){
  544. self.optimize();
  545. });
  546. var builder = createConcatenator();
  547. builder.add('#!/usr/bin/env node');
  548. builder.start();
  549. program_files.forEach(function(file) {
  550. if(fs.existsSync(file)) {
  551. console.log('Adding : ' + file);
  552. var buffer = fs.readFileSync(file);
  553. // matches and returns the "module_id" string in the AMD define: define("module_id", ...)
  554. var match = buffer.toString().match(/^define\("([^"]*)"/);
  555. if (match /*&& match[1].slice(0,9) !== "amber_vm/"*/) {
  556. builder.addId(match[1]);
  557. }
  558. builder.add(buffer);
  559. } else {
  560. fileStream.end();
  561. throw(new Error('Can not find file ' + file));
  562. }
  563. });
  564. var mainFunctionOrFile = '';
  565. if (undefined !== defaults.main) {
  566. console.log('Adding call to: %s>>main', defaults.main);
  567. mainFunctionOrFile += 'smalltalk.' + defaults.main + '._main();';
  568. }
  569. if (undefined !== defaults.mainfile && fs.existsSync(defaults.mainfile)) {
  570. console.log('Adding main file: ' + defaults.mainfile);
  571. mainFunctionOrFile += '\n' + fs.readFileSync(defaults.mainfile);
  572. }
  573. builder.finish(mainFunctionOrFile);
  574. console.log('Writing...');
  575. builder.forEach(function (element) {
  576. fileStream.write(element);
  577. fileStream.write('\n');
  578. });
  579. console.log('Done.');
  580. fileStream.end();
  581. };
  582. /**
  583. * Optimize created JavaScript files with Google Closure compiler depending
  584. * on the flag: defaults.closure_full.
  585. */
  586. AmberC.prototype.optimize = function() {
  587. var defaults = this.defaults;
  588. var self = this;
  589. var optimization_done = new Combo(function() {
  590. console.log = console.ambercLog;
  591. console.timeEnd('Compile Time');
  592. if (undefined !== defaults.finished_callback) {
  593. defaults.finished_callback();
  594. }
  595. });
  596. if (defaults.closure_full && (undefined !== defaults.program)) {
  597. var programFile = defaults.program;
  598. if (undefined !== defaults.output_dir) {
  599. programFile = path.join(defaults.output_dir, programFile);
  600. }
  601. console.log('Compiling ' + programFile + '.js file using Google closure compiler.');
  602. self.closure_compile(programFile + '.js', programFile + '.min.js', optimization_done.add());
  603. }
  604. always_resolve(optimization_done.add());
  605. };
  606. /**
  607. * Compile sourceFile into minifiedFile with Google Closure compiler.
  608. * callback gets executed once finished.
  609. */
  610. AmberC.prototype.closure_compile = function(sourceFile, minifiedFile, callback) {
  611. // exec is asynchronous
  612. var self = this;
  613. exec(
  614. 'java -jar ' +
  615. self.closure_jar + ' ' +
  616. self.defaults.closure_options +
  617. ' --js '+ sourceFile +
  618. ' --js_output_file '+ minifiedFile,
  619. function (error, stdout, stderr) {
  620. if (error) {
  621. console.log(stderr);
  622. } else {
  623. console.log(stdout);
  624. console.log('Minified: '+ minifiedFile);
  625. }
  626. callback();
  627. }
  628. );
  629. };
  630. module.exports.Compiler = AmberC;
  631. module.exports.createDefaults = createDefaults;
  632. module.exports.Combo = Combo;
  633. module.exports.map = async_map;