Skip to content

Commit

Permalink
feat(ignore): implement the ignore option
Browse files Browse the repository at this point in the history
  • Loading branch information
skovy committed Dec 8, 2019
1 parent 9eccb80 commit 6e20dc5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const { _: patterns, ...rest } = yargs
"$0 src/**/*.scss --aliasPrefixes.~ ./node_modules/",
'Replace the "~" prefix with "./node_modules/" for all imports beginning with "~"'
)
.example(
"$0 src/**/*.scss --ignore **/secret.scss",
'Ignore any file names "secret.scss"'
)
.demandCommand(1)
.option("aliases", {
coerce: (obj): Aliases => obj,
Expand Down Expand Up @@ -81,6 +85,12 @@ const { _: patterns, ...rest } = yargs
string: true,
alias: "i",
describe: "Additional paths to include when trying to resolve imports."
})
.option("ignore", {
string: true,
array: true,
default: [],
describe: "Add a pattern or an array of glob patterns to exclude matches."
}).argv;

main(patterns[0], { ...rest });
6 changes: 3 additions & 3 deletions lib/core/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const generate = async (
pattern: string,
options: MainOptions
): Promise<void> => {
// Find all the files that match the provied pattern.
const files = glob.sync(pattern);
// Find all the files that match the provided pattern.
const files = glob.sync(pattern, { ignore: options.ignore });

if (!files || !files.length) {
alerts.error("No files found.");
Expand All @@ -30,7 +30,7 @@ export const generate = async (
);
}

alerts.success(`Found ${files.length} files. Generating type defintions...`);
alerts.success(`Found ${files.length} files. Generating type definitions...`);

// Wait for all the type definitions to be written.
await Promise.all(files.map(file => writeFile(file, options)));
Expand Down
1 change: 1 addition & 0 deletions lib/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Options } from "../sass";
import { ExportType } from "../typescript";

export interface MainOptions extends Options {
ignore: string[];
exportType: ExportType;
listDifferent: boolean;
watch: boolean;
Expand Down
3 changes: 2 additions & 1 deletion lib/core/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const watch = (pattern: string, options: MainOptions): void => {

chokidar
.watch(pattern, {
ignoreInitial: options.ignoreInitial
ignoreInitial: options.ignoreInitial,
ignored: options.ignore
})
.on("change", path => {
alerts.info(`[CHANGED] ${path}`);
Expand Down

0 comments on commit 6e20dc5

Please sign in to comment.