| 37 | } |
| 38 | |
| 39 | function deps(msg: Msg): PlugDeps { |
| 40 | return { |
| 41 | spinner: () => ({ |
| 42 | start() {}, |
| 43 | stop() {}, |
| 44 | }), |
| 45 | log: { |
| 46 | error() {}, |
| 47 | info() {}, |
| 48 | success() {}, |
| 49 | }, |
| 50 | resolve: async () => msg.target, |
| 51 | readText: (file) => Filesystem.readText(file), |
| 52 | write: async (file, text) => { |
| 53 | if (msg.holdMs && msg.holdMs > 0) { |
| 54 | await sleep(msg.holdMs) |
| 55 | } |
| 56 | await Filesystem.write(file, text) |
| 57 | }, |
| 58 | exists: (file) => Filesystem.exists(file), |
| 59 | files: (dir, name) => [path.join(dir, `${name}.jsonc`), path.join(dir, `${name}.json`)], |
| 60 | global: msg.globalDir ?? path.join(msg.dir, ".global"), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | function ctx(msg: Msg): PlugCtx { |
| 65 | return { |