Describe the bug
The following config does not resolve properly, it returns an error:
// @ts-check
/* eslint-disable no-undef */
/* @type {import('simple-scaffold').ScaffoldConfigFile} */
const conf = () => {
const story = process.argv.includes("--story")
const test = process.argv.includes("--test")
if (story) {
process.argv.splice(process.argv.indexOf("--story"), 1)
}
if (test) {
process.argv.splice(process.argv.indexOf("--test"), 1)
}
const templates = [
"gen/component",
...(story ? [] : ["!gen/component/*.stories.tsx"]),
...(test ? [] : ["!gen/component/*.test.tsx"]),
]
const component = (/** @type {string} */ type) => {
console.log("Processing: ", [...process.argv], { story, test, templates })
return {
templates: templates,
output: `src/${type}`,
createSubFolder: true,
subFolderNameHelper: "pascalCase",
data: {
element: "div",
type,
},
}
}
return {
atom: component("atoms"),
molecule: component("molecules"),
organism: component("organisms"),
page: {
templates: ["gen/page"],
output: "src/pages",
createSubFolder: true,
subFolderNameHelper: "pascalCase",
data: {
element: "Card",
type: "page",
},
},
}
}
module.exports = conf
Expected behavior**
Should run the function, get the default key, then use that response as the config.
Right now, it sees "default" after resolving, instead of seeing the keys returned from default.
Logs
$ npx simple-scaffold@latest --config ./gen/scaffold.config.cjs --key atom --story test
Loading config from ./gen/scaffold.config.cjs with key atom
Loading config from file ./gen/scaffold.config.cjs
/Users/planck/.npm/_npx/42a4b0a410ce2116/node_modules/simple-scaffold/config.js:74
throw new Error(`Template "${key}" not found in ${configFile}. Available keys: ${Object.keys(configImport).join(", ")}`);
^
Error: Template "atom" not found in ./gen/scaffold.config.cjs. Available keys: default
at parseConfig (/Users/planck/.npm/_npx/42a4b0a410ce2116/node_modules/simple-scaffold/config.js:74:13)
at async Massarg._main (/Users/planck/.npm/_npx/42a4b0a410ce2116/node_modules/simple-scaffold/cmd.js:21:25)
Describe the bug
The following config does not resolve properly, it returns an error:
Expected behavior**
Should run the function, get the default key, then use that response as the config.
Right now, it sees "default" after resolving, instead of seeing the keys returned from default.
Logs