Skip to content

Commit

Permalink
feat: Add FileList.readOne to scan for file dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidmt committed Sep 16, 2020
1 parent 4fcf1ac commit befa799
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/ui.files/files.list.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
const { flatten, distinct, split, last, map, pipe } = require("m.xyz")
const { buildList } = require("just-a-list.redux")
const { sep } = require("path")
const glob = require("glob")
const dependencyTree = require("dependency-tree")
const { sep } = require("path")
const { buildList } = require("just-a-list.redux")
const { flatten, distinct, split, last, map, pipe } = require("m.xyz")

const FileList = buildList({
name: "FILES",

// @signature (fileGlob: String[]): Object[]
read: fileGlob => {
return pipe(
map(item => glob.sync(item, { absolute: true })),
flatten,
distinct,
map(item => {
return {
id: item,
name: pipe(split(sep), last)(item),
isRunning: false,
code: null,
}
})
)(fileGlob)
},
read: pipe(
map(item => glob.sync(item, { absolute: true })),
flatten,
distinct,
map(item => {
return {
id: item,
name: pipe(split(sep), last)(item),
isRunning: false,
code: null,
}
})
),

readOne: id => ({
id,
shouldRunOnChange: dependencyTree.toList({
filename: id,
directory: __dirname,
filter: path => path.indexOf("node_modules") === -1,
}),
}),

update: (id, data) => ({
id,
Expand Down

0 comments on commit befa799

Please sign in to comment.