Skip to content

Commit

Permalink
feat: add watch option to bundle, fmt and lint commands
Browse files Browse the repository at this point in the history
  • Loading branch information
umbopepato committed Jan 16, 2022
1 parent bfceeca commit 4e76fc0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cli_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ Deno.test("tsconfig", async () => {
assertStringIncludes(output, expectedOutput);
});

Deno.test("config", async () => {
const output = await runScript("config", yamlWd);
assertMatch(output, /^\s*$/);
});

Deno.test("import map", async () => {
const output = await runScript("importMap");
assertStringIncludes(output, expectedOutput);
Expand All @@ -97,11 +102,6 @@ Deno.test("--help", async () => {
assertStringIncludes(output, "--version");
});

Deno.test("--config", async () => {
const output = await runScript("config", yamlWd);
assertMatch(output, /^\s*$/);
});

Deno.test("forward arguments", async () => {
const output = await runScript("forward", yamlWd, ["--shuffle=1234"]);
assertStringIncludes(
Expand Down
13 changes: 9 additions & 4 deletions src/build_command_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum DenoOptions {
shuffle = "shuffle",
}

const denoCmdOptions: { [key: string]: DenoOptions[] } = {
export const denoCmdOptions: { [key: string]: DenoOptions[] } = {
bundle: [
DenoOptions.cert,
DenoOptions.config,
Expand All @@ -38,6 +38,7 @@ const denoCmdOptions: { [key: string]: DenoOptions[] } = {
DenoOptions.reload,
DenoOptions.tsconfig,
DenoOptions.unstable,
DenoOptions.watch,
],
install: [
DenoOptions.allow,
Expand Down Expand Up @@ -161,12 +162,14 @@ const denoCmdOptions: { [key: string]: DenoOptions[] } = {
DenoOptions.log,
DenoOptions.quiet,
DenoOptions.unstable,
DenoOptions.watch,
],
lint: [
DenoOptions.config,
DenoOptions.log,
DenoOptions.quiet,
DenoOptions.unstable,
DenoOptions.watch,
],
types: [
DenoOptions.log,
Expand All @@ -184,7 +187,7 @@ const denoCmdOptions: { [key: string]: DenoOptions[] } = {
],
};

const denoOption: Record<DenoOptions, string> = {
export const denoOption: Record<DenoOptions, string> = {
...DenoOptions,
[DenoOptions.allow]: "allow-",
[DenoOptions.importMap]: "import-map",
Expand Down Expand Up @@ -278,7 +281,9 @@ export function buildCommandString(command: Command): string {

default: {
if (optionName === "imap") {
console.warn("The `imap` option is deprecated in favor of `importMap`. Please use `importMap` going forward as `imap` will be removed with the release of 2.0.0.");
console.warn(
"The `imap` option is deprecated in favor of `importMap`. Please use `importMap` going forward as `imap` will be removed with the release of 2.0.0.",
);
}
cmd = insertOptions(
cmd,
Expand Down Expand Up @@ -307,7 +312,7 @@ function insertOptions(

function generateFlagOptions(
flags: FlagsObject,
prefix: string = "",
prefix = "",
): string[] {
return Object.entries(flags).map(([k, v]) =>
`--${prefix}${k}${v !== true ? `="${escapeCliOption(v.toString())}"` : ""}`
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class RunCommand extends Command {
this.description("Run a script")
.arguments("<script:scriptid> [additionalArgs...]")
.useRawArgs()
.action((options, script: string, ...additionalArgs: string[]) => {
.action((_, script: string, ...additionalArgs: string[]) => {
return withUpdateChecks(async () => {
if (script === "--help" || script === "-h") {
console.log(this.getHelp());
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class UpgradeCommand extends Command {
"Upgrade Velociraptor to the latest version or to a specific one",
)
.arguments("[version:string]")
.action(async (options, version: string | undefined) => {
.action(async (_, version: string | undefined) => {
let newVersion = version;
if (!newVersion) {
newVersion = await DenoLand.latestVersion(VR_NAME);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/vr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class VrCommand extends Command {
.type("scriptid", new ScriptIdType(this.configData), { global: true })
.arguments("[script:scriptid] [additionalArgs...]")
.stopEarly()
.action((options, script: string, additionalArgs: string[]) => {
.action((_, script: string, additionalArgs: string[]) => {
return withUpdateChecks(async () => {
validateConfigData(this.configData);
await checkGitHooks(this.configData as ConfigData);
Expand Down
2 changes: 1 addition & 1 deletion src/scripts_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export interface DenoCliOptions {
cert?: string;

/**
* The path to a deno configuration file,
* The path to a deno/TypeScript configuration file,
* passed to deno cli's `--config` option.
*/
config?: string;
Expand Down
4 changes: 2 additions & 2 deletions test/yaml/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ scripts:
cmd: deno run test.ts
tsconfig: tsconfig.json
importMap:
cmd: deno run --unstable import_map.ts
cmd: deno run import_map.ts
importMap: import_map.json
forward:
cmd: echo deno test --lock=lock.json --cached-only
config:
cmd: deno lint test_config.ts
config: ../json/deno.jsonc
config: ../json/deno.jsonc

0 comments on commit 4e76fc0

Please sign in to comment.