-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(versioncmd): add version command
- Loading branch information
Showing
8 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2018 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { | ||
Command, | ||
CommandResult, | ||
CommandParams, | ||
} from "./base" | ||
import { getPackageVersion } from "../cli/helpers" | ||
import chalk from "chalk" | ||
|
||
export class VersionCommand extends Command { | ||
name = "version" | ||
help = "Show's the current cli version." | ||
|
||
async action({ log }: CommandParams<{}>): Promise<CommandResult<String>> { | ||
const result = `${getPackageVersion()}` | ||
|
||
log.info(`${chalk.white(result)}`) | ||
return { result } | ||
} | ||
} |
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,19 @@ | ||
/* | ||
* Copyright (C) 2018 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { expect } from "chai" | ||
import { getPackageVersion } from "../../../src/cli/helpers" | ||
|
||
describe("helpers", () => { | ||
describe("getPackageVersion", () => { | ||
it("returns the version in package.json", async () => { | ||
const version = require("../../../package.json").version | ||
expect(getPackageVersion()).to.eq(version) | ||
}) | ||
}) | ||
}) |
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,19 @@ | ||
import { expect } from "chai" | ||
import { VersionCommand } from "../../../src/commands/version" | ||
import { makeTestGardenA } from "../../helpers" | ||
|
||
describe("VersionCommand", () => { | ||
it("should return the current package's version", async () => { | ||
const command = new VersionCommand() | ||
const garden = await makeTestGardenA() | ||
const log = garden.log | ||
const result = await command.action({ | ||
log, | ||
garden, | ||
args: {}, | ||
opts: {}, | ||
}) | ||
|
||
expect(result.result).to.eql(require("../../../package.json").version) | ||
}) | ||
}) |