Skip to content

Commit

Permalink
Merge pull request #48 from nielsmaerten/feature/skipPathConfirmation
Browse files Browse the repository at this point in the history
feat: skip import path confirmation
  • Loading branch information
nielsmaerten authored Sep 23, 2022
2 parents 0d09676 + fa8e613 commit 3916deb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/how-to-configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import_from: "/home/niels/downloads" # linux, mac os
**Optional:** If no folder is set, ynab-buddy will ask where to find your files every time.
### `skip_path_confirmation`

Set to `true` to always use `import_from` without confirmation


**Optional.**

### `search_subfolders`

```yaml
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { exportCsv, findBankFiles, cleanup } from "./lib/filesystem";
import { parseBankFile } from "./lib/parser";
import { upload } from "./lib/uploader";
import { BankFile } from "./types";
import fs from "fs";

(async () => {
// Ensure the tool has a valid configuration
Expand All @@ -17,7 +18,11 @@ import { BankFile } from "./types";
if (!config.configurationDone) return cli.exitApp();

// Confirm folder where the tool should look for bank files
config.importPath = await cli.confirmImportPath(config.importPath);
const importPathExists =
config.importPath && fs.existsSync(config.importPath);
if (!config.skipPathConfirmation || !importPathExists) {
config.importPath = await cli.confirmImportPath(config.importPath);
}

// Find files eligible for conversion in the importPath
const bankFiles = findBankFiles(config.importPath!, config);
Expand Down
1 change: 1 addition & 0 deletions src/lib/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe("configuration", () => {
pattern: "BNP-export-IBAN01233456789-*.csv",
},
],
skipPathConfirmation: false,
configurationDone: false,
parsers: [
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const readConfigFile = () => {
const parseRawConfig = (rawConfig: any): Configuration => {
return {
importPath: rawConfig.import_from,
skipPathConfirmation: !!rawConfig.skip_path_confirmation,
searchSubDirectories: !!rawConfig.search_subdirectories,
bankFilePatterns: rawConfig.bank_transaction_files,
ynab: {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type Configuration = {
importPath?: string; // FIXME: Can i remove the '?' ?
skipPathConfirmation?: boolean;
searchSubDirectories: boolean;
parsers: Parser[];
bankFilePatterns: BankFilePattern[];
Expand Down

0 comments on commit 3916deb

Please sign in to comment.