-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli-plugin-deploy-pulumi): update config resolution logic
- Loading branch information
Showing
3 changed files
with
52 additions
and
9 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/cli-plugin-deploy-pulumi/commands/watch/WebinyConfigFile.js
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
class LocalFile { | ||
constructor(filePath) { | ||
this.filePath = filePath; | ||
} | ||
|
||
exists() { | ||
return fs.existsSync(this.filePath); | ||
} | ||
|
||
getAbsolutePath() { | ||
return this.filePath; | ||
} | ||
} | ||
|
||
class WebinyConfigFile { | ||
constructor(root) { | ||
this.potentialConfigs = [ | ||
new LocalFile(path.join(root, "webiny.config.ts")), | ||
new LocalFile(path.join(root, "webiny.config.js")) | ||
]; | ||
} | ||
|
||
static forWorkspace(workspace) { | ||
return new WebinyConfigFile(path.resolve(workspace)); | ||
} | ||
|
||
getAbsolutePath() { | ||
const file = this.potentialConfigs.find(file => file.exists()); | ||
if (!file) { | ||
return undefined; | ||
} | ||
|
||
return file.getAbsolutePath(); | ||
} | ||
} | ||
|
||
module.exports = { WebinyConfigFile }; |
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