diff options
| author | Di Peng | 2011-08-15 16:17:12 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-09-13 01:02:22 +0200 | 
| commit | a13653c81431bf51fed2a958514ebfb9aeb2dc14 (patch) | |
| tree | 3a2b81ff8661aa8b3b0d8bdbc5d01d2e54023d6f /gen_jstd_configs.js | |
| parent | 8017340cd106156e84508fa8061bd98004eff487 (diff) | |
| download | angular.js-a13653c81431bf51fed2a958514ebfb9aeb2dc14.tar.bz2 | |
refactor(angular): externalize script load order into JSON
- move all script load order into angularFiles.js
- rakefile and angular-bootstrap.js use angularFiles.js to get script orders
- gen_jstd_configs.js uses angularFiles.js to generate various jstd config files
- run gen_jstd_configs.js whenever we run server.sh
Closes #470
Diffstat (limited to 'gen_jstd_configs.js')
| -rwxr-xr-x | gen_jstd_configs.js | 43 | 
1 files changed, 43 insertions, 0 deletions
| diff --git a/gen_jstd_configs.js b/gen_jstd_configs.js new file mode 100755 index 00000000..15d8491d --- /dev/null +++ b/gen_jstd_configs.js @@ -0,0 +1,43 @@ +#!/usr/bin/env node +/* This file reads in list of files from angularFiles.js and generate various jstd config files */ + +var fs = require('fs'), +    angularSrc, +    angularScenario; + +fs.readFile('angularFiles.js', function(err, data) { +  eval(data.toString()); +  var prefix = 'server: http://localhost:9876\n\n', +      prefixScenario = 'server: http://localhost:9877\n\n'; + +  angularSrc = angularFiles.angularSrc.join('\n- '); +  angularScenario = angularFiles.angularScenario.join('\n- '); + +  fs.writeFile('./jsTestDriver.conf', prefix + combine(angularFiles.jstd, +      angularFiles.jstdExclude)); + +  fs.writeFile('./jsTestDriver-scenario.conf', prefixScenario + +      combine(angularFiles.jstdScenario) + +      '\n\nproxy:\n- {matcher: "*", server: "http://localhost:8000"}'); + +  fs.writeFile('./jsTestDriver-perf.conf', prefix + combine(angularFiles.jstdPerf, +      angularFiles.jstdPerfExclude)); + +  fs.writeFile('./jsTestDriver-jquery.conf', prefix + combine(angularFiles.jstdJquery, +      angularFiles.jstdJqueryExclude)); + +  fs.writeFile('./jsTestDriver-coverage.conf', prefix + +      combine(angularFiles.jstd, angularFiles.jstdExclude) + +      '\n\nplugin:\n- name: "coverage"\n' + +      'jar: "lib/jstestdriver/coverage.jar"\n' + +      'module: "com.google.jstestdriver.coverage.CoverageModule"'); +}); + +function combine(load, exclude) { +  var fileList = 'load:\n- ' + load.join('\n- '); +  if (exclude) fileList += ('\n\nexclude:\n- ' + exclude.join('\n- ')); + +  //Replace placeholders for src list before returning +  return fileList.replace(/@angularSrc/g, angularSrc); +} + | 
