-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧪 test(none): improve coverage (#2599)
- **🔨 improve(patch): add @types/node to create bud app** - **🧪 test(none): improve @roots/bud-api coverage**
- Loading branch information
1 parent
63225e4
commit 3793d13
Showing
69 changed files
with
1,362 additions
and
326 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
40 changes: 0 additions & 40 deletions
40
sources/@roots/bud-api/src/methods/compilePaths/compilePaths.ts
This file was deleted.
Oops, something went wrong.
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,6 +1,49 @@ | ||
export {compilePaths} from './compilePaths.js' | ||
import type {Rules} from '@roots/bud-framework' | ||
import type {Bud, Rules} from '@roots/bud-framework' | ||
|
||
type Source = Array<RegExp | string> | RegExp | string | ||
import {InputError} from '@roots/bud-support/errors' | ||
import isArray from '@roots/bud-support/isArray' | ||
import isString from '@roots/bud-support/isString' | ||
|
||
export type Source = Array<RegExp | string> | RegExp | string | ||
|
||
export type Parameters = [Source, Array<`${keyof Rules & string}`>?] | ||
|
||
export interface compilePaths { | ||
(this: Bud, ...value: Parameters): Bud | ||
} | ||
|
||
export const compilePaths: compilePaths = function (sources, rules) { | ||
const sourcesArray = isArray(sources) ? sources : [sources] | ||
|
||
sourcesArray.forEach(source => { | ||
if (!isString(source) && !(source instanceof RegExp)) { | ||
throw new InputError( | ||
`bud.compilePaths: source must be a string or a regular expression.`, | ||
) | ||
} | ||
}) | ||
|
||
this.hooks.action(`build.before`, async bud => { | ||
const keys: Array<`${keyof Rules & string}`> = (rules ?? | ||
Object.keys(bud.build.rules)) as `${keyof Rules & string}`[] | ||
|
||
const matches = keys.map(key => { | ||
const match = bud.build.getRule(key) | ||
|
||
if (!match) { | ||
throw new InputError( | ||
`bud.compilePaths: \`${key}\` is not a valid rule name.`, | ||
) | ||
} | ||
|
||
return match | ||
}) | ||
|
||
matches.map(rule => { | ||
bud.api.logger.log(`setting compile paths for ${rule.getTest()}`) | ||
rule.setInclude(sourcesArray) | ||
}) | ||
}) | ||
|
||
return this | ||
} |
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
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
Oops, something went wrong.