You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
directory | `String/Array` | directories to be loaded
228
229
target | `Object` | attach the target object from loaded files
229
-
match | `String/Array` | match the files when load, default to `**/*.js`
230
+
match | `String/Array` | match the files when load, default to `**/*.js`(if typescript was true, default to `[ '**/*.(js|ts)', '!**/*.d.ts' ]`)
231
+
typescript | `Boolean` | whether support typescript
230
232
ignore | `String/Array` | ignore the files when load
231
233
initializer | `Function` | custom file exports, receive two parameters, first is the inject object(if not js file, will be content buffer), second is an `options` object that contain `path`
232
234
caseStyle | `String/Function` | set property's case when converting a filepath to property list.
Copy file name to clipboardExpand all lines: lib/loader/file_loader.js
+13-2Lines changed: 13 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ const defaults = {
15
15
directory: null,
16
16
target: null,
17
17
match: undefined,
18
+
typescript: false,
18
19
ignore: undefined,
19
20
lowercaseFirst: false,
20
21
caseStyle: 'camel',
@@ -37,6 +38,7 @@ class FileLoader {
37
38
* @param {String|Array} options.directory - directories to be loaded
38
39
* @param {Object} options.target - attach the target object from loaded files
39
40
* @param {String} options.match - match the files when load, support glob, default to all js files
41
+
* @param {Boolean} options.typescript - whether support typescript, default to false
40
42
* @param {String} options.ignore - ignore the files when load, support glob
41
43
* @param {Function} options.initializer - custom file exports, receive two parameters, first is the inject object(if not js file, will be content buffer), second is an `options` object that contain `path`
42
44
* @param {Boolean} options.call - determine whether invoke when exports is function
@@ -48,6 +50,9 @@ class FileLoader {
48
50
constructor(options){
49
51
assert(options.directory,'options.directory is required');
50
52
assert(options.target,'options.target is required');
53
+
if(options.typescript){
54
+
assert(require.extensions['.ts'],'`require.extensions` should contains `.ts` while `options.typescript` was true');
0 commit comments