mediasnacks 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install-zsh-completions.js +3 -3
- package/package.json +1 -1
- package/src/openrand.js +8 -6
|
@@ -25,7 +25,7 @@ function makeScript() {
|
|
|
25
25
|
return `#compdef mediasnacks
|
|
26
26
|
|
|
27
27
|
_mediasnacks_commands=(
|
|
28
|
-
${commandsSummary().map(([cmd, desc]) => `'${cmd}:${desc}'`).join('\n')}
|
|
28
|
+
${commandsSummary().map(([cmd, desc]) => `'${cmd}:${desc.trim()}'`).join('\n')}
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
if (( CURRENT == 2 )); then
|
|
@@ -35,8 +35,8 @@ fi
|
|
|
35
35
|
|
|
36
36
|
local cmd="$words[2]"
|
|
37
37
|
case "$cmd" in
|
|
38
|
-
qdir)
|
|
39
|
-
|
|
38
|
+
qdir|openrand)
|
|
39
|
+
_path_files -/
|
|
40
40
|
;;
|
|
41
41
|
*)
|
|
42
42
|
_files
|
package/package.json
CHANGED
package/src/openrand.js
CHANGED
|
@@ -6,21 +6,23 @@ import { parseOptions } from './utils/parseOptions.js'
|
|
|
6
6
|
|
|
7
7
|
const HELP = `
|
|
8
8
|
SYNOPSIS
|
|
9
|
-
mediasnacks openrand [-r | --recursive]
|
|
9
|
+
mediasnacks openrand [-r | --recursive] [dir]
|
|
10
10
|
|
|
11
11
|
DESCRIPTION
|
|
12
|
-
Opens a random file in
|
|
12
|
+
Opens a random file in a dir on macOS.
|
|
13
|
+
The dir defaults to the current working directory.
|
|
13
14
|
`
|
|
14
15
|
|
|
15
16
|
export default async function main() {
|
|
16
|
-
const { values } = await parseOptions(HELP, {
|
|
17
|
+
const { values, positionals } = await parseOptions(HELP, {
|
|
17
18
|
recursive: { short: 'r', type: 'boolean' },
|
|
18
19
|
})
|
|
19
20
|
|
|
20
21
|
if (process.platform !== 'darwin')
|
|
21
22
|
throw 'This command is only supported on macOS.'
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
const dir = positionals[0] || '.'
|
|
25
|
+
openrand(dir, values.recursive)
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export function openrand(dir = '.', recursive = false) {
|
|
@@ -29,7 +31,7 @@ export function openrand(dir = '.', recursive = false) {
|
|
|
29
31
|
|
|
30
32
|
export function pickRandomFile(dir = '.', recursive = false) {
|
|
31
33
|
const files = readdirSync(dir, { withFileTypes: true, recursive })
|
|
32
|
-
.filter(
|
|
33
|
-
.map(
|
|
34
|
+
.filter(dirent => !dirent.name.startsWith('.') && dirent.isFile())
|
|
35
|
+
.map(dirent => join(dirent.parentPath, dirent.name))
|
|
34
36
|
return files[Math.floor(Math.random() * files.length)]
|
|
35
37
|
}
|