Skip to content

Commit

Permalink
improvement: check that the static dir exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharbonnier authored and edvald committed Sep 4, 2019
1 parent 40588bd commit 5ba7b34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions garden-service/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
parseLogLevel,
helpTextMaxWidth,
checkForUpdates,
checkForStaticDir,
} from "./helpers"
import { defaultEnvironments, ProjectConfig } from "../config/project"
import {
Expand Down Expand Up @@ -315,6 +316,8 @@ export class GardenCli {
// tslint:disable-next-line: no-floating-promises
checkForUpdates(garden.globalConfigStore, headerLog)

await checkForStaticDir()

// TODO: enforce that commands always output DeepPrimitiveMap
result = await command.action({
garden,
Expand Down
14 changes: 13 additions & 1 deletion garden-service/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import axios from "axios"
import qs = require("qs")
import { platform, release } from "os"
import { LogEntry } from "../logger/log-entry"
import { VERSION_CHECK_URL } from "../constants"
import { STATIC_DIR, VERSION_CHECK_URL } from "../constants"
import { printWarningMessage } from "../logger/util"
import { GlobalConfigStore, globalConfigKeys } from "../config-store"
import moment = require("moment")
import { pathExists } from "fs-extra"

// Parameter types T which map between the Parameter<T> class and the Sywac cli library.
// In case we add types that aren't supported natively by Sywac, see: http://sywac.io/docs/sync-config.html#custom
Expand Down Expand Up @@ -216,6 +217,17 @@ export function failOnInvalidOptions(argv, ctx) {
}
}

export async function checkForStaticDir() {
if (!(await pathExists(STATIC_DIR))) {
throw new InternalError(
`Could not find the static data directory. Garden is packaged with a data directory ` +
`called 'static', which should be located next to your garden binary. Please try reinstalling, ` +
`and make sure the release archive is fully extracted to the target directory.`,
{},
)
}
}

export async function checkForUpdates(config: GlobalConfigStore, logger: LogEntry) {
if (process.env.GARDEN_DISABLE_VERSION_CHECK === "true") {
return
Expand Down

0 comments on commit 5ba7b34

Please sign in to comment.