|
|
@ -1,9 +1,18 @@ |
|
|
|
import { EOL } from 'os' |
|
|
|
import { EOL } from 'os' |
|
|
|
import { SearchResultLineLine } from '../../types' |
|
|
|
import { SearchResultLineLine } from '../../types' |
|
|
|
|
|
|
|
import isElectron from 'is-electron' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const getDirectory = async (dir: string, plugin: any) => { |
|
|
|
export const getDirectory = async (dir: string, plugin: any) => { |
|
|
|
let result = [] |
|
|
|
let result = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isElectron()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const files = await plugin.call('fs', 'glob', dir, '**/*') |
|
|
|
|
|
|
|
// only get path property of files
|
|
|
|
|
|
|
|
result = files.map(x => x.path) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
const files = await plugin.call('fileManager', 'readdir', dir) |
|
|
|
const files = await plugin.call('fileManager', 'readdir', dir) |
|
|
|
const fileArray = normalize(files) |
|
|
|
const fileArray = normalize(files) |
|
|
|
for (const fi of fileArray) { |
|
|
|
for (const fi of fileArray) { |
|
|
@ -16,6 +25,7 @@ export const getDirectory = async (dir: string, plugin: any) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return result |
|
|
|
return result |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|