Skip to content

Commit

Permalink
feat: When creating config file set .yaml extension
Browse files Browse the repository at this point in the history
- Explicitly set config extension to `.yaml` as recommended in YAML specs
- Update dependencies
  • Loading branch information
nikolay-borzov committed Apr 20, 2021
1 parent 4449cf9 commit 2db1bc0
Show file tree
Hide file tree
Showing 9 changed files with 552 additions and 444 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module.exports = {
root: true,
ignorePatterns: ['**/*.*', '!**/*.js', '!**/*.cjs', 'node_modules', '/dist'],
ignorePatterns: [
'**/*.*',
'!**/*.js',
'!**/*.cjs',
'node_modules',
'/dist',
'/coverage',
],
env: {
node: true,
},
Expand Down Expand Up @@ -71,7 +78,6 @@ module.exports = {
overrides: [
{
files: 'tests/**/*',
plugins: ['ava'],
extends: ['plugin:ava/recommended'],
},
],
Expand Down
5 changes: 3 additions & 2 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
'**/*.?(c)js': (filenames) => [
`eslint --cache --fix ${filenames.join(' ')}`,
'ava',
'ava --fail-fast',
],
'**/*.*': 'prettier --write --ignore-unknown',
// Format supported non JavaScript files
'**/*.!(?(c)js)': 'prettier --write --ignore-unknown',
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[style-guide-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[style-guide-url]: https://standardjs.com

CLI utility deletes files not listed in selected torrent. Useful when torrent is updated and some files have been removed.
CLI utility deletes files not listed in the selected torrent. Useful when torrent is updated and some files have been removed.

## Install

Expand Down
4 changes: 2 additions & 2 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { deleteFilesAndEmptyDirectories } from './delete-files.js'
* @property {string} torrentName Parsed torrent name.
* @property {string[]} extraFiles Extra files' paths.
* @property {(files: string[]) => Promise<void>} deleteFiles Function to
* delete files in the directory. Has effect only if `dryRun` is set to `true`.
* delete files in the directory. Has effect only if `dryRun` was set to `true`.
*/

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function cleanTorrentDirectory({

const { name, files } = parseResult

// Get absolute paths of torrent files
// Get absolute paths of torrent's files
const torrentFiles = new Set(
files.map((file) => path.join(directoryPath, file).toLowerCase())
)
Expand Down
10 changes: 4 additions & 6 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,9 @@ export async function loadConfig(searchFrom, customConfig) {
.filter(Boolean)
.reduce((result, config) => merge(result, config), {})

if (mergedConfig.ignore) {
mergedConfig.ignore = [...IGNORE_GLOBS, ...mergedConfig.ignore]
} else {
mergedConfig.ignore = IGNORE_GLOBS
}
mergedConfig.ignore = mergedConfig.ignore
? [...IGNORE_GLOBS, ...mergedConfig.ignore]
: IGNORE_GLOBS

return {
config: mergedConfig,
Expand Down Expand Up @@ -145,7 +143,7 @@ export function saveConfig({ config, saveDirectoryPath, existingConfigPath }) {
: YAML.stringify(config)

const filename =
existingConfigPath || path.join(saveDirectoryPath, `.${MODULE_NAME}rc`)
existingConfigPath || path.join(saveDirectoryPath, `.${MODULE_NAME}rc.yaml`)

fs.writeFileSync(filename, fileContent)
}
Loading

0 comments on commit 2db1bc0

Please sign in to comment.