Skip to content

Commit

Permalink
Rename ensureDirectoryExistence -> ensureDirectoryExists
Browse files Browse the repository at this point in the history
  • Loading branch information
svsool committed Jul 30, 2020
1 parent b7df0d5 commit 27c5ce4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/commands/openDocumentByReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
containsImageExt,
getWorkspaceCache,
findUriByRef,
ensureDirectoryExistence,
ensureDirectoryExists,
parseRef,
} from '../utils';

Expand All @@ -28,7 +28,7 @@ const openDocumentByReference = async ({ reference }: { reference: string }) =>

// don't override file content if it already exists
if (!fs.existsSync(filePath)) {
ensureDirectoryExistence(filePath);
ensureDirectoryExists(filePath);
fs.writeFileSync(filePath, '');
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/createDailyQuickPick.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('createDailyQuickPick()', () => {
expect(dailyQuickPick.items).toHaveLength(63);
});

it('should contain an item with an indicator on note existence', async () => {
it('should contain an item with an indicator about note existence', async () => {
const dateInYYYYMMDDFormat = moment().format('YYYY-MM-DD');

await createFile(`${dateInYYYYMMDDFormat}.md`);
Expand Down
5 changes: 2 additions & 3 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,10 @@ export const findUriByRef = (uris: vscode.Uri[], ref: string): vscode.Uri | unde
return containsMarkdownExt(path.basename(uri.fsPath)) && name === ref.toLowerCase();
});

// TODO: Rename to ensureDirectoryExists
export const ensureDirectoryExistence = (filePath: string) => {
export const ensureDirectoryExists = (filePath: string) => {
const dirname = path.dirname(filePath);
if (!fs.existsSync(dirname)) {
ensureDirectoryExistence(dirname);
ensureDirectoryExists(dirname);
fs.mkdirSync(dirname);
}
};
Expand Down

0 comments on commit 27c5ce4

Please sign in to comment.