Skip to content

Commit

Permalink
include prettier ignore in format command
Browse files Browse the repository at this point in the history
  • Loading branch information
electrovir committed Oct 19, 2021
1 parent faad1a3 commit 81e48cc
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "virmator",
"version": "1.3.6",
"version": "1.3.7",
"description": "Handle all the stuffs in one package.",
"keywords": [
"automation",
Expand Down
48 changes: 48 additions & 0 deletions src/cli/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ testGroup({
runTest({
description: 'verify that format config is created',
expect: [
{
name: 'previous config exists',
result: false,
},
{
name: 'previous config exists',
result: false,
Expand All @@ -250,6 +254,10 @@ testGroup({
name: 'config was created',
result: true,
},
{
name: 'config was created',
result: true,
},
{
name: 'second format has stderr',
result: false,
Expand All @@ -258,6 +266,10 @@ testGroup({
name: 'config exists after cleanup',
result: false,
},
{
name: 'config exists after cleanup',
result: false,
},
{
name: 'symlink exists after cleanup',
result: false,
Expand All @@ -269,6 +281,10 @@ testGroup({
testFormatPaths.validRepo,
getRepoConfigFilePath(ConfigKey.Prettier, false),
),
join(
testFormatPaths.validRepo,
getRepoConfigFilePath(ConfigKey.PrettierIgnore, false),
),
]),
});

Expand All @@ -283,6 +299,10 @@ testGroup({
name: 'previous config exists',
result: false,
},
{
name: 'previous config exists',
result: false,
},
{
name: 'symlink was created',
result: true,
Expand All @@ -299,6 +319,10 @@ testGroup({
name: 'config was created',
result: true,
},
{
name: 'config was created',
result: true,
},
{
name: 'second format has stderr',
result: false,
Expand All @@ -311,6 +335,10 @@ testGroup({
name: 'config exists after cleanup',
result: false,
},
{
name: 'config exists after cleanup',
result: false,
},
{
name: 'symlink exists after cleanup',
result: false,
Expand All @@ -326,6 +354,10 @@ testGroup({
testFormatPaths.validRepo,
getExtendableBaseConfigName(ConfigKey.Prettier),
),
join(
testFormatPaths.validRepo,
getRepoConfigFilePath(ConfigKey.PrettierIgnore, false),
),
]),
});

Expand All @@ -340,6 +372,10 @@ testGroup({
name: 'previous config exists',
result: false,
},
{
name: 'previous config exists',
result: false,
},
{
name: 'symlink was created',
result: true,
Expand All @@ -352,6 +388,10 @@ testGroup({
name: 'config was created',
result: true,
},
{
name: 'config was created',
result: true,
},
{
name: 'second format has stderr',
result: false,
Expand All @@ -360,6 +400,10 @@ testGroup({
name: 'config exists after cleanup',
result: false,
},
{
name: 'config exists after cleanup',
result: false,
},
{
name: 'symlink exists after cleanup',
result: false,
Expand Down Expand Up @@ -402,6 +446,10 @@ module.exports = {...baseConfig, printWidth: 80};`;
testFormatPaths.validRepo,
getExtendableBaseConfigName(ConfigKey.Prettier),
),
join(
testFormatPaths.validRepo,
getRepoConfigFilePath(ConfigKey.PrettierIgnore, false),
),
],
)),
);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/implementations/format.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const formatImplementation: CliCommandImplementation = {
${packageName} ${CliCommandName.Format} --ignore-path .prettierignore
${packageName} ${CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore
${packageName} ${CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore ${filesMarkerArg} md json`,
configKeys: [ConfigKey.Prettier],
configKeys: [ConfigKey.Prettier, ConfigKey.PrettierIgnore],
implementation: runFormatCommand,
configFlagSupport: {
[CliFlagName.NoWriteConfig]: true,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/run-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function runCommand(
const defaultFlagSupport = {
[CliFlagName.Silent]: true,
[CliFlagName.Help]: true,
[CliFlagName.ExtendableConfig]: !!commandImplementation.configKeys?.every((configKey) =>
[CliFlagName.ExtendableConfig]: !!commandImplementation.configKeys?.some((configKey) =>
isExtendableConfig(configKey),
),
};
Expand Down
2 changes: 1 addition & 1 deletion src/cli/config/config-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export enum BareConfigKey {
GitHubActionsPrerelease = 'GitHubActionsPrerelease',
GitIgnore = 'GitIgnore',
NpmIgnore = 'NpmIgnore',
PrettierIgnore = 'PrettierIgnore',
VsCodeSettings = 'VsCodeSettings',
}

Expand All @@ -16,6 +15,7 @@ export enum CommandConfigKey {
Prettier = 'Prettier',
TsConfig = 'TsConfig',
PackageJson = 'PackageJson',
PrettierIgnore = 'PrettierIgnore',
}

export const ConfigKey = {...CommandConfigKey, ...BareConfigKey};
Expand Down
2 changes: 1 addition & 1 deletion src/cli/config/copy-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function copyConfig({
});
}

if (shouldExtend) {
if (shouldExtend && isExtendableConfig(configKey)) {
if (!isExtendableConfig(configKey)) {
throw new ConfigFileError(`Extendable config files are not supported for ${configKey}`);
}
Expand Down

0 comments on commit 81e48cc

Please sign in to comment.