Skip to content

Commit

Permalink
Fix to setting config manually
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinmcfarland committed Aug 7, 2024
1 parent 6c2dc14 commit fddf310
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions mole.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"folders": [
{
"path": "."
}
]
}
1 change: 0 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const handleWarnings = (warning, warn) => {
warn(warning);
};

// Export default configuration
export default [
{
input: 'src/index.js',
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class Config {
return this
}
async set(value) {
// console.log(value)

// Get the input value for the config

let input
// Check if value is a path to a file or an object
if (typeof value === 'string') {
Expand Down Expand Up @@ -70,6 +71,7 @@ class Config {
// We assign the new properties to the Config object
Object.assign(this, result)

// console.log("---", result)

}
}
Expand Down
15 changes: 10 additions & 5 deletions src/lib/Mole.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,30 @@ function isFunction(functionToCheck) {
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
}

let customConfigPath

async function getConfig() {
if (env === 'test') {
await config.set('src/stub/config.cjs')
return config
} else {
}
if (customConfigPath) {
await config.set(customConfigPath)
return config
}
else {
await config.set('mole.config.js')
configS = config
return config
}
}

class Mole {
constructor() { }
config(value) {
config.set(value)
customConfigPath = value
}
theme(value) {

getConfig().then((config) => {
theme.set(value, config)
})
Expand Down Expand Up @@ -101,8 +108,6 @@ class Mole {
}
async _outputs() {



things = (await getConfig()).output.map(async output => {

return await Output.createInstance(output, peripherals, config, theme, data)
Expand Down

0 comments on commit fddf310

Please sign in to comment.