@private @method _getAssetPath @param {(Object|String)} asset @return {(String|undefined)} assetPath
(asset)
| 1221 | @return {(String|undefined)} assetPath |
| 1222 | */ |
| 1223 | _getAssetPath(asset) { |
| 1224 | /* @type {String} */ |
| 1225 | let assetPath; |
| 1226 | |
| 1227 | if (typeof asset !== 'object') { |
| 1228 | assetPath = asset; |
| 1229 | } else if (this.env in asset) { |
| 1230 | assetPath = asset[this.env]; |
| 1231 | } else { |
| 1232 | assetPath = asset.development; |
| 1233 | } |
| 1234 | |
| 1235 | if (!assetPath) { |
| 1236 | return; |
| 1237 | } |
| 1238 | |
| 1239 | assetPath = assetPath.split('\\').join('/'); |
| 1240 | |
| 1241 | if (assetPath.split('/').length < 2) { |
| 1242 | console.log( |
| 1243 | chalk.red( |
| 1244 | `Using \`app.import\` with a file in the root of \`vendor/\` causes a significant performance penalty. Please move \`${assetPath}\` into a subdirectory.` |
| 1245 | ) |
| 1246 | ); |
| 1247 | } |
| 1248 | |
| 1249 | if (/[*,]/.test(assetPath)) { |
| 1250 | throw new Error( |
| 1251 | `You must pass a file path (without glob pattern) to \`app.import\`. path was: \`${assetPath}\`` |
| 1252 | ); |
| 1253 | } |
| 1254 | |
| 1255 | return assetPath; |
| 1256 | } |
| 1257 | |
| 1258 | /** |
| 1259 | Returns an array of trees for this application |