generated from darkobits/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Configuration files may export arrays.
- Loading branch information
Showing
8 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { UserConfigurationFn } from './UserConfigurationFn'; | ||
|
||
/** | ||
* The value default-exported from a user's configuration file may be either a | ||
* single function or an array of functions, each of which will be passed a | ||
* context object. | ||
*/ | ||
export type UserConfigurationExport = UserConfigurationFn | Array<UserConfigurationFn>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import type { UserConfigurationFn } from 'etc/types'; | ||
import type { UserConfigurationExport } from 'etc/types'; | ||
|
||
|
||
/** | ||
* Optional helper for users who prefer to have typed configuration files. | ||
*/ | ||
export function defineConfig(userConfigFactory: UserConfigurationFn): UserConfigurationFn { | ||
return async context => userConfigFactory(context); | ||
export default function defineConfig(userConfigArgument: UserConfigurationExport): UserConfigurationExport { | ||
return Array.isArray(userConfigArgument) | ||
? userConfigArgument.map(userConfigurationFn => async context => userConfigurationFn(context)) | ||
: async context => userConfigArgument(context); | ||
} | ||
|
||
|
||
export default defineConfig; | ||
|
||
|
||
export * from 'etc/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters