Skip to content

Commit 6fdc2c0

Browse files
authored
Merge pull request #94 from pfirpfel/es-modules
Es modules
2 parents 0ab69a1 + 4e48a11 commit 6fdc2c0

File tree

7 files changed

+962
-714
lines changed

7 files changed

+962
-714
lines changed

.eslintrc.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import globals from "globals";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import js from "@eslint/js";
5+
import { FlatCompat } from "@eslint/eslintrc";
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
const compat = new FlatCompat({
10+
baseDirectory: __dirname,
11+
recommendedConfig: js.configs.recommended,
12+
allConfig: js.configs.all
13+
});
14+
15+
export default [...compat.extends("eslint:recommended"), {
16+
languageOptions: {
17+
globals: {
18+
...globals.node,
19+
...globals.commonjs,
20+
},
21+
22+
ecmaVersion: "latest",
23+
sourceType: "module",
24+
},
25+
26+
rules: {},
27+
}];

index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#!/usr/bin/env node
2-
const process = require('node:process');
3-
const path = require('path');
4-
const { listFiles, createDirectoryIfNotExists, writeFile, readYamlFile, findFile } = require('./src/util');
5-
const { download, checkDependencies } = require('./src/youtube-dl');
6-
const ejs = require('ejs');
2+
import process from 'node:process';
3+
import path from 'path';
4+
import { listFiles, createDirectoryIfNotExists, writeFile, readYamlFile, findFile } from './src/util.js';
5+
import { download, checkDependencies } from './src/youtube-dl.js';
6+
import ejs from 'ejs';
7+
import yargs from "yargs";
8+
import { fileURLToPath } from 'url';
9+
import { dirname } from 'path';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = dirname(__filename);
713

814
async function main() {
915
const { yamlDir, templatesPath, outPath } = parseArgs();
@@ -16,7 +22,7 @@ async function main() {
1622
}
1723

1824
function parseArgs() {
19-
const argv = require('yargs/yargs')(process.argv.slice(2))
25+
const argv = yargs(process.argv.slice(2))
2026
.usage('Usage: $0 -d [directory]')
2127
.alias('d', 'directory')
2228
.nargs('d', 1)

0 commit comments

Comments
 (0)