-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from 343dev/improvement/cleaning
Move to ESM
- Loading branch information
Showing
17 changed files
with
8,073 additions
and
3,852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
const { program } = require('commander'); | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const markdownLint = require('.'); | ||
const { prepareExtensions } = require('./lib/utils'); | ||
import { program } from 'commander'; | ||
|
||
const { version, description } = require('./package.json'); | ||
import markdownLint from './index.js'; | ||
import { prepareExtensions } from './lib/utils.js'; | ||
|
||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const { version, description } = JSON.parse(await fs.readFile(path.join(dirname, 'package.json'))); | ||
|
||
program | ||
.option('--fix', 'Automatically fix problems') | ||
.option('--ext <value>', 'Specify file extensions', prepareExtensions, ['md', 'MD']) | ||
.option('-t, --typograph', 'Enable typograph') | ||
.option('-r, --recursive', 'Get files from provided directory and the entire subtree') | ||
.option('-c, --config <file>', 'Use this configuration, overriding default options if present'); | ||
.option('--fix', 'Automatically fix problems') | ||
.option('--ext <value>', 'Specify file extensions', prepareExtensions, ['md', 'MD']) | ||
.option('-t, --typograph', 'Enable typograph') | ||
.option('-r, --recursive', 'Get files from provided directory and the entire subtree') | ||
.option('-c, --config <file>', 'Use this configuration, overriding default options if present'); | ||
|
||
program | ||
.usage('[options] <dir> <file ...>') | ||
.version(version, '-v, --version') | ||
.description(description) | ||
.parse(process.argv); | ||
.usage('[options] <dir> <file ...>') | ||
.version(version, '-v, --version') | ||
.description(description) | ||
.parse(process.argv); | ||
|
||
if (!program.args.length) { | ||
program.help(); | ||
if (program.args.length === 0) { | ||
program.help(); | ||
} else { | ||
markdownLint({ | ||
paths: program.args, | ||
fix: program.fix, | ||
ext: program.ext, | ||
recursive: program.recursive, | ||
config: program.config, | ||
typograph: program.typograph, | ||
}); | ||
const options = program.opts(); | ||
|
||
markdownLint({ | ||
paths: program.args, | ||
fix: options.fix, | ||
ext: options.ext, | ||
recursive: options.recursive, | ||
config: options.config, | ||
typograph: options.typograph, | ||
}); | ||
} |
Oops, something went wrong.