Skip to content

Commit

Permalink
test: - Code simplifications: use node:path for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
claremacrae committed Nov 22, 2024
1 parent eb0a408 commit 5e9d698
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('node:fs');
const util = require('util');
const path = require('node:path');

const vault = app.vault;

Expand All @@ -10,20 +10,18 @@ async function getMarkdownFiles() {
}

function getBasename(filePath) {
return filePath.split('/')[1].replace('.md', '');
return path.basename(filePath, '.md');
}

function getOutputFilePath(outputFile) {
const rootOfVault = vault.adapter.getBasePath();
return rootOfVault + '/../../../tests/Obsidian/' + outputFile;
return path.join(rootOfVault, '../../../tests/Obsidian', outputFile);
}

function writeFile(testSourceFile, content) {
fs.writeFile(testSourceFile, content, (err) => {
if (err) {
console.error(err);
} else {
// file written successfully
}
});
}
Expand Down

0 comments on commit 5e9d698

Please sign in to comment.