tasks/lib/lang-aliases.js
function runLanguageHandler(src) {
  // execute source code in an isolated sandbox with a mock PR object
  var sandbox = createSandbox();
  vm.runInNewContext(fs.readFileSync(src), sandbox, {
    filename: src
  });

  // language name
  var lang = path.basename(src, path.extname(src)).replace(/^lang-/, '');

  // collect and filter extensions
  var exts = sandbox.extensions.map(function (ext) {
    // case-insensitive names
    return ext.toLowerCase();
  }).filter(function (ext) {
    // skip self, and internal names like foo-bar-baz or lang.foo
    return ext !== lang && !/\W/.test(ext);
  });
  exts = exts.filter(function (ext, pos) {
    // remove duplicates
    return exts.indexOf(ext) === pos;
  });
  return exts;
}
function runLanguageHandler(src) {
  // execute source code in an isolated sandbox with a mock PR object
  var sandbox = createSandbox();
  vm.runInNewContext(fs.readFileSync(src), sandbox, {
    filename: src
  });

  // language name
  var lang = path.basename(src, path.extname(src)).replace(/^lang-/, '');

  // collect and filter extensions
  var exts = sandbox.extensions.map(function (ext) {
    // case-insensitive names
    return ext.toLowerCase();
  }).filter(function (ext) {
    // skip self, and internal names like foo-bar-baz or lang.foo
    return ext !== lang && !/\W/.test(ext);
  });
  exts = exts.filter(function (ext, pos) {
    // remove duplicates
    return exts.indexOf(ext) === pos;
  });
  return exts;
}
function runLanguageHandler ( src ) { // execute source code in an isolated sandbox with a mock PR object var sandbox = createSandbox ( ) ; vm . runInNewContext ( fs . readFileSync ( src ) , sandbox , { filename : src } ) ; // language name var lang = path . basename ( src , path . extname ( src ) ) . replace ( / ^lang- / , '' ) ; // collect and filter extensions var exts = sandbox . extensions . map ( function ( ext ) { // case-insensitive names return ext . toLowerCase ( ) ; } ) . filter ( function ( ext ) { // skip self, and internal names like foo-bar-baz or lang.foo return ext !== lang && ! / \W / . test ( ext ) ; } ) ; exts = exts . filter ( function ( ext , pos ) { // remove duplicates return exts . indexOf ( ext ) === pos ; } ) ; return exts ; }
Runs a language handler file under VM to collect extensions.

Given a lang-*.js file, runs the language handler in a fake context where
PR.registerLangHandler collects handler names without doing anything else.
This is later used to makes copies of the JS extension under all its
registered language names lang-<EXT>.js

@param {string} src path to lang-xxx.js language handler
@return {Array<string>} registered file extensions
Runs a language handler file under VM to collect extensions .