Skip to content

Commit

Permalink
chore: adjust custom lint script
Browse files Browse the repository at this point in the history
  • Loading branch information
mujahidkay committed Oct 3, 2024
1 parent 8311170 commit 62d523d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { promises as fs } from 'fs';
import { glob } from 'glob';

const fs = require('fs').promises;
const glob = require('glob');
const util = require('util');
const globPromise = util.promisify(glob);

const extractJsSnippets = (markdownContent) => {
const pattern = /```(?:js|javascript)\n([\s\S]*?)```/g;
Expand Down Expand Up @@ -163,7 +164,7 @@ const lintMarkdownFile = async (filePath, fix = false) => {
};
const processFiles = async (globPattern, fix = false) => {
try {
const files = await glob(globPattern);
const files = await globPromise(globPattern);
if (files.length === 0) {
console.error('No files found matching the pattern.');
process.exit(1);
Expand Down Expand Up @@ -231,7 +232,4 @@ const main = async () => {
await processFiles(globPattern, fix);
};

main().catch(error => {
console.error(`Unhandled error: ${error.message}`);
process.exit(1);
});
module.exports = main;
13 changes: 13 additions & 0 deletions scripts/run-linter.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import main from './markdown-js-snippets-linter.cjs';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const linterPath = join(__dirname, 'markdown-js-snippets-linter.mjs');

main().catch(error => {
console.error(`Unhandled error: ${error.message}`);
process.exit(1);
});

0 comments on commit 62d523d

Please sign in to comment.