File tree Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ import alfy from 'alfy';
4
4
import { filterOutput , findFilter , isFileAction } from './src/utils.js' ;
5
5
6
6
const { inputWithoutFilter, foundFilter : filter } = findFilter ( alfy . input ) ;
7
- const input = inputWithoutFilter . replaceAll ( '\t' , '\n' ) . split ( '\n' ) ;
7
+ const input = inputWithoutFilter
8
+ . replaceAll ( "\t" , "\n" )
9
+ . split ( "\n" )
10
+ . map ( ( element ) => element . trim ( ) ) ;
8
11
9
12
const options = [
10
13
{
@@ -77,7 +80,7 @@ function run(input) {
77
80
}
78
81
79
82
return options . map ( options => {
80
- const files = input . map ( filepath => options . action ( filepath . trim ( ) ) ) . filter ( element => Boolean ( element ) ) ;
83
+ const files = input . map ( filepath => options . action ( filepath ) ) . filter ( element => Boolean ( element ) ) ;
81
84
return {
82
85
title : `${ options . prefix } : ${ files } ` ,
83
86
subtitle : 'Copy to clipboard' ,
Original file line number Diff line number Diff line change @@ -22,19 +22,12 @@ export function filterOutput(filter, output) {
22
22
}
23
23
24
24
export function isFileAction ( input ) {
25
- input = Array . isArray ( input ) ? input : [ input ] ;
26
- const filePaths = input . map ( filepath => {
27
- if ( filepath . slice ( 0 , 1 ) !== '/' ) {
28
- return false ;
29
- }
30
-
31
- const stat = fs . lstatSync ( filepath . trim ( ) ) ;
32
- if ( stat . isFile ( ) || stat . isDirectory ( ) ) {
33
- return true ;
34
- }
35
-
36
- return false ;
37
- } )
38
- . filter ( element => Boolean ( element ) ) ;
25
+ const filePaths = input
26
+ . filter ( ( element ) => Boolean ( element . trim ( ) ) )
27
+ . filter ( filepath => {
28
+ if ( filepath . slice ( 0 , 1 ) !== '/' ) return false ;
29
+ const stat = fs . lstatSync ( filepath . trim ( ) ) ;
30
+ return ( stat . isFile ( ) || stat . isDirectory ( ) )
31
+ } )
39
32
return filePaths . length > 0 ;
40
33
}
You can’t perform that action at this time.
0 commit comments