Skip to content

Commit

Permalink
fix: add project paths to reliably construct file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Mar 19, 2020
1 parent 14af4c7 commit 180f96f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/cli/commands/api/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { green, red } = require("chalk");
const notifier = require("node-notifier");
const { execute } = require("../utils/execute");
const { isApiEnvDeployed } = require("../utils");
const { paths } = require("../utils/paths");

const perks = ["🍪", "☕️", "🍎", "🍺", "🥤"];

Expand All @@ -19,7 +20,7 @@ const notify = ({ message }) => {

module.exports = async inputs => {
const { env } = inputs;
const webinyJs = resolve("webiny.js");
const webinyJs = resolve(paths.projectRoot, "webiny.js");
const config = require(webinyJs);

const isFirstDeploy = !(await isApiEnvDeployed(env));
Expand All @@ -37,7 +38,7 @@ module.exports = async inputs => {
// Run app state hooks
if (!fs.existsSync(webinyJs)) {
console.log(
`⚠️ ${green("webiny.config.js")} was not found at ${green(
`⚠️ ${green("webiny.js")} was not found at ${green(
webinyJs
)}, skipping processing of hooks.`
);
Expand All @@ -47,7 +48,7 @@ module.exports = async inputs => {

for (let i = 0; i < config.apps.length; i++) {
const app = config.apps[i];
const appLocation = resolve(app.location);
const appLocation = resolve(paths.projectRoot, app.location);
try {
const { hooks } = require(join(appLocation, "webiny"));
if (hooks && hooks.stateChanged) {
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/commands/utils/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require("path");
const projectRoot = process.cwd();

const resolve = (...dir) => {
return path.resolve(projectRoot, ...dir);
};

module.exports.paths = {
projectRoot,
packagesPath: resolve("packages"),
apiPath: resolve("api"),
appPath: resolve("apps"),
apiYaml: resolve("api", "serverless.yml"),
appsYaml: resolve("apps", "serverless.yml")
};

0 comments on commit 180f96f

Please sign in to comment.