allow app/jsx/bundles/<name>.js for js bundles

closes: CNVS-35702

This makes it so you don’t have to create a coffeescript
file to make a new bundle. Putting a file in:
app/jsx/bundles/foobar.js
will be treated exactly the same as:
app/coffeescripts/bundles/foobar.coffee

So from here on out, there is no excuses to create
new coffeescript files :)


Test plan:
* in the next commit I will actually move a couple
  CoffeeScript files to be javascript files in the
  jsx folder and it will make more sense

Change-Id: Ib5911b0a19760d66f43889c94f91fdd1eb9f85e9
Reviewed-on: https://gerrit.instructure.com/105166
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2017-03-14 16:48:32 -06:00
parent 66b390fe68
commit d6cda30564
1 changed files with 7 additions and 6 deletions

View File

@ -2,10 +2,11 @@ const glob = require('glob')
const entries = {}
const bundlesPattern = __dirname + '/../app/coffeescripts/bundles/**/*.coffee'
const pluginBundlesPattern = __dirname + '/../gems/plugins/*/app/coffeescripts/bundles/*.coffee'
const bundleNameRegexp = /\/coffeescripts\/bundles\/(.*).coffee/
const fileNameRegexp = /\/([^/]+)\.coffee/
const bundlesPattern = __dirname + '/../app/{jsx,coffeescripts}/bundles/**/*.{coffee,js}'
const pluginBundlesPattern = __dirname + '/../gems/plugins/*/app/{jsx,coffeescripts}/bundles/**/*.{coffee,js}'
const bundleNameRegexp = /\/(coffeescripts|jsx)\/bundles\/(.*).(coffee|js)/
const fileNameRegexp = /\/([^/]+)\.(coffee|js)/
const pluginNameRegexp = /plugins\/([^/]+)\/app/
const appBundles = glob.sync(bundlesPattern, [])
@ -17,8 +18,8 @@ const pluginBundles = glob.sync(pluginBundlesPattern, [])
const nonEntryPoints = ['modules/account_quota_settings', 'modules/content_migration_setup']
appBundles.forEach((entryFilepath) => {
const entryBundlePath = entryFilepath.replace(/^.*app\/coffeescripts\/bundles/, './app/coffeescripts/bundles')
const entryName = bundleNameRegexp.exec(entryBundlePath)[1]
const entryBundlePath = entryFilepath.replace(/^.*app\/(coffeescripts|jsx)\/bundles/, (_, dir) => `./app/${dir}/bundles`)
const entryName = bundleNameRegexp.exec(entryBundlePath)[2]
if (!nonEntryPoints.includes(entryName)) {
entries[entryName] = entryBundlePath
}