@@ -20,38 +20,51 @@ import { TopBunAggregateError } from './lib/helpers/top-bun-aggregate-error.js'
2020*/
2121
2222/**
23- * @template T extends Object. <string, any>
23+ * @template {Record <string, any>} T
2424 * @typedef {import('./lib/build-pages/resolve-layout.js').LayoutFunction<T> } LayoutFunction
2525 */
2626
2727/**
28- * @template T extends Object. <string, any>
28+ * @template {Record <string, any>} T
2929 * @typedef {import('./lib/build-pages/resolve-vars.js').PostVarsFunction<T> } PostVarsFunction
3030 */
3131
3232/**
33- * @template T extends Object. <string, any>
33+ * @template {Record <string, any>} T
3434 * @typedef {import('./lib/build-pages/page-builders/page-writer.js').PageFunction<T> } PageFunction
3535 */
3636
3737/**
38- * @template T extends Object. <string, any>
38+ * @template {Record <string, any>} T
3939 * @typedef {import('./lib/build-pages/page-builders/template-builder.js').TemplateFunction<T> } TemplateFunction
4040 */
4141
4242/**
43- * @template T extends Object. <string, any>
43+ * @template {Record <string, any>} T
4444 * @typedef {import('./lib/build-pages/page-builders/template-builder.js').TemplateAsyncIterator<T> } TemplateAsyncIterator
4545 */
4646
4747/**
4848 * @typedef {import('./lib/build-pages/page-builders/template-builder.js').TemplateOutputOverride } TemplateOutputOverride
4949 */
5050
51+ const DEFAULT_IGNORES = /** @type {const } */ ( [
52+ '.*' ,
53+ 'coverage' ,
54+ 'node_modules' ,
55+ 'package.json' ,
56+ 'package-lock.json' ,
57+ 'pnpm-lock.yaml' ,
58+ 'yarn.lock' ,
59+ ] )
60+
61+ /**
62+ * @template {TopBunOpts} [CurrentOpts=TopBunOpts]
63+ */
5164export class TopBun {
5265 /** @type {string } */ #src = ''
5366 /** @type {string } */ #dest = ''
54- /** @type {TopBunOpts } */ opts = { }
67+ /** @type {Readonly<CurrentOpts & { ignore: string[] }> } */ opts
5568 /** @type {FSWatcher? } */ #watcher = null
5669 /** @type {any? } */ #cpxWatcher = null
5770 /** @type {browserSync.BrowserSyncInstance? } */ #browserSyncServer = null
@@ -60,20 +73,24 @@ export class TopBun {
6073 *
6174 * @param {string } src - The src path of the page build
6275 * @param {string } dest - The dest path of the page build
63- * @param {TopBunOpts } [opts] - The options for the site build
76+ * @param {CurrentOpts } [opts] - The options for the site build
6477 */
65- constructor ( src , dest , opts = { } ) {
66- assert ( src , 'src is a required argument' )
67- assert ( dest , 'dest is a required argument' )
68-
69- const defaultIgnore = [ '.*' , 'node_modules' , basename ( dest ) , 'package.json' , 'pacakge-lock.json' ]
70-
71- opts . ignore = defaultIgnore . concat ( makeArray ( opts . ignore ) )
78+ constructor ( src , dest , opts = /** @type {CurrentOpts } */ ( { } ) ) {
79+ if ( ! src || typeof src !== 'string' ) throw new TypeError ( 'src should be a (non-empty) string' )
80+ if ( ! dest || typeof dest !== 'string' ) throw new TypeError ( 'dest should be a (non-empty) string' )
81+ if ( ! opts || typeof opts !== 'object' ) throw new TypeError ( 'opts should be an object' )
7282
7383 this . #src = src
7484 this . #dest = dest
7585
76- this . opts = opts
86+ this . opts = {
87+ ...opts ,
88+ ignore : [
89+ ...DEFAULT_IGNORES ,
90+ basename ( dest ) ,
91+ ...makeArray ( opts . ignore ) ,
92+ ] ,
93+ }
7794 }
7895
7996 get watching ( ) {
0 commit comments