Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setState({
files: map(item =>
item.path === file.path
? {
...item,
...file,
isLoading: false,
}
: item
)(files),
})
})
// default state
this.state = {
files: map(
(item): TestFile => ({
path: item,
name: basename(item),
stdout: "",
stderr: "",
code: -1,
isLoading: false,
})
)(filePaths),
fileSelectedPath: filePaths[0],
filterQuery: "",
runArgs: this.executorRunArgs,
isDebugVisible: false,
isFilterVisible: false,
}
}
constructor(props: Props) {
super(props)
const { requireModules, filePattern, rootPath } = props
const filePaths = glob.sync(`**/${filePattern}`, {
absolute: true,
cwd: rootPath,
})
// Offloading all file execution to secondary process
this.executor = fork(`${__dirname}/../lib/executor.js`)
this.executorRunArgs = reduce(
(acc, item): string[] => [...acc, "-r", item],
[]
)(requireModules)
// Update state with file data coming from secondary forked process
this.executor &&
this.executor.on("message", (file: TestFile) => {
const { files } = this.state
this.setState({
files: map(item =>
item.path === file.path
? {
...item,
...file,
isLoading: false,
this.refFilterInput.on("keypress", (code, key) => {
if (!isEmpty(code) && /[a-zA-Z0-9 \-=\.]/.test(code)) {
this.handleInputAdd(code)
}
if (key.full === "backspace") {
this.handleInputPop()
}
})
render = () => {
const { label, value, top, left, width, height } = this.props
return (
`${entryKey}: ${JSON.stringify(entryValue)}`
),
join("\n")
)(value)}
/>
)
}
}
onSelect(map(get("id"))(items))
break
case "r":
onSelect(items[position].id)
break
case "home":
onChange(
pipe(
head,
get("id")
)(items)
)
break
case "end":
onChange(
pipe(
tail,
get("id")
)(items)
)
break
case "k":
case "up":
onChange(items[max([0, position - 1])].id)
break
case "j":
case "down":
onChange(items[min([items.length - 1, position + 1])].id)
break
case "pageup":
onChange(items[max([0, position - pageSize])].id)
break
actions: {
xHandleChangeSelected,
xHandleRun,
xHandleFilterChange,
xHandleFilterSubmit,
xHandleFilterClose,
},
} = this.props
const filesSelected: TestFile =
findBy({ path: fileSelectedPath })(files) ?? {}
const filesFiltered = filter(item => contains(filterQuery)(item.path))(
files
)
const listWidth =
pipe(
map(item => item.name.length),
max
)(files) + 6
return [
,
file: {
i: isDebugVisible ? "Hide details" : "Show details",
},
global: {
"C-c": "Exit",
},
}
return [
({ ...acc, ...value })),
Object.entries,
reduce(
(acc = "", [key, value]): string =>
`${acc}{white-bg}{black-fg}${key}{/} ${value} `
)
)(actions)}
/>,
handleMoveKeys = (code: string, key: Object) => {
const { items, onChange, onSelect } = this.props
const { position } = this.state
const pageSize = this.refList.height - 2
switch (key.full) {
case "M-r":
onSelect(map(get("id"))(items))
break
case "r":
onSelect(items[position].id)
break
case "home":
onChange(
pipe(
head,
get("id")
)(items)
)
break
case "end":
onChange(
pipe(
tail,
get("id")
)(items)
)
break
case "k":
case "up":
onChange(items[max([0, position - 1])].id)
handleMoveKeys = (code: string, key: Object) => {
const { items, onChange, onSelect } = this.props
const { position } = this.state
const pageSize = this.refList.height - 2
switch (key.full) {
case "M-r":
onSelect(map(get("id"))(items))
break
case "r":
onSelect(items[position].id)
break
case "home":
onChange(
pipe(
head,
get("id")
)(items)
)
break
case "end":
onChange(
pipe(
tail,
xHandleChangeSelected,
xHandleRun,
xHandleFilterChange,
xHandleFilterSubmit,
xHandleFilterClose,
},
} = this.props
const filesSelected: TestFile =
findBy({ path: fileSelectedPath })(files) ?? {}
const filesFiltered = filter(item => contains(filterQuery)(item.path))(
files
)
const listWidth =
pipe(
map(item => item.name.length),
max
)(files) + 6
return [
,