@thegetty/quire-cli 1.0.0 → 1.0.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/11ty/api.js +9 -28
- package/src/lib/11ty/cli.js +1 -2
package/package.json
CHANGED
package/src/lib/11ty/api.js
CHANGED
|
@@ -51,37 +51,12 @@ const factory = async (options = {}) => {
|
|
|
51
51
|
* @param {String} input Path from which to read content templates
|
|
52
52
|
* @param {String} output Path where rendered files will be written
|
|
53
53
|
* @param {Object} options Options are merged with the Eleventy UserConfig
|
|
54
|
-
* @
|
|
54
|
+
* @property {string} config Config callback run after initialization
|
|
55
55
|
*
|
|
56
56
|
* @returns {module:11ty/eleventy/Eleventy~Eleventy}
|
|
57
57
|
*/
|
|
58
58
|
const eleventy = new Eleventy(input, output, {
|
|
59
59
|
config: (eleventyConfig) => {
|
|
60
|
-
/**
|
|
61
|
-
* Override addPassthroughCopy to use _absolute_ system paths.
|
|
62
|
-
* @see https://www.11ty.dev/docs/copy/#passthrough-file-copy
|
|
63
|
-
* Nota bene: Eleventy addPassthroughCopy assumes paths are _relative_
|
|
64
|
-
* to the `config` file however the quire-cli separates 11ty from the
|
|
65
|
-
* project directory (`input`) and needs to use absolute system paths.
|
|
66
|
-
*/
|
|
67
|
-
const addPassthroughCopy = eleventyConfig.addPassthroughCopy.bind(eleventyConfig)
|
|
68
|
-
eleventyConfig.addPassthroughCopy = (entry) => {
|
|
69
|
-
if (typeof entry === 'string') {
|
|
70
|
-
const filePath = path.resolve(entry) //path.join(projectRoot, file)
|
|
71
|
-
// console.debug('[11ty:API] passthrough copy %s', filePath)
|
|
72
|
-
return addPassthroughCopy(filePath, copyOptions)
|
|
73
|
-
} else {
|
|
74
|
-
// console.debug('[11ty:API] passthrough copy %o', entry)
|
|
75
|
-
entry = Object.fromEntries(
|
|
76
|
-
Object.entries(entry).map(([ src, dest ]) => {
|
|
77
|
-
return [ path.join(eleventyRoot, src), path.resolve(dest) ]
|
|
78
|
-
})
|
|
79
|
-
)
|
|
80
|
-
// console.debug('[11ty:API] passthrough copy %o', entry)
|
|
81
|
-
return addPassthroughCopy(entry, copyOptions)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
60
|
/**
|
|
86
61
|
* Event callback when a build completes
|
|
87
62
|
* @see https://www.11ty.dev/docs/events/#eleventy.after
|
|
@@ -89,11 +64,10 @@ const factory = async (options = {}) => {
|
|
|
89
64
|
eleventyConfig.on('eleventy.after', async () => {
|
|
90
65
|
console.debug('[11ty:API] build complete')
|
|
91
66
|
})
|
|
92
|
-
|
|
93
|
-
return eleventyConfig
|
|
94
67
|
},
|
|
95
68
|
configPath: options.config || config,
|
|
96
69
|
quietMode: options.quiet || false,
|
|
70
|
+
runMode: process.env.ELEVENTY_ENV === 'production' ? 'build' : 'serve'
|
|
97
71
|
})
|
|
98
72
|
|
|
99
73
|
return eleventy
|
|
@@ -128,7 +102,14 @@ export default {
|
|
|
128
102
|
if (options.debug) process.env.DEBUG = 'Eleventy*'
|
|
129
103
|
|
|
130
104
|
const eleventy = await factory(options)
|
|
105
|
+
await eleventy.init()
|
|
106
|
+
await eleventy.watch()
|
|
131
107
|
|
|
132
108
|
await eleventy.serve(options.port)
|
|
109
|
+
|
|
110
|
+
process.on("SIGINT", async () => {
|
|
111
|
+
await eleventy.stopWatch()
|
|
112
|
+
process.exit(0)
|
|
113
|
+
})
|
|
133
114
|
}
|
|
134
115
|
}
|