var glob = require('glob');
var fs   = require('fs');
var log  = console.log.bind(console);
var save = fs.writeFileSync.bind(fs);

/**
 * Rebuild the assets array for Typescript
 */
module.exports = function rebuildAssetsIndex() {
  log("# Rebuilding assets index");
  var files = glob.sync("./assets/**/*.*");
  var tmpl  = 'export = FILES;'.replace("FILES", JSON.stringify(files));
  save("./assets/generated.ts", tmpl);
  log("# Finished rebuilding assets index");
}