mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
Quest: remove unnecessary ls-stages (#195)
* quest: remove ls-stages in create * feat: prevent throwing errors when failed to copy files * feat: log new command in dev mode * quest: copy * quest: mv * quest: rm * quest: execute. Add many exceptions * feat: pwd discovers parent folders
This commit is contained in:
1 parent
f0a09ac4d9
commit
3b77d91796
9 files changed
+147
-217
No files matched your search
@@ -1,4 +1,5 @@
|
||||
const fs = require('fs').promises
|
||||
const path = require('path')
|
||||
const minimist = require('minimist')
|
||||
const { discoverFiles, collectFilesInfo } = require('./discover')
|
||||
const { resolvePath } = require('./utils')
|
||||
@@ -43,6 +44,9 @@ const commandListeners = {
|
||||
mv: {
|
||||
handler: moveFiles,
|
||||
},
|
||||
pwd: {
|
||||
handler: showCurrentPath,
|
||||
},
|
||||
}
|
||||
|
||||
async function handleCommand(command) {
|
||||
@@ -149,4 +153,22 @@ async function moveFiles(argv) {
|
||||
return results
|
||||
}
|
||||
|
||||
function showCurrentPath() {
|
||||
const pwd = process.cwd()
|
||||
const dirs = pwd.split('/')
|
||||
let currentPath = '/'
|
||||
const result = []
|
||||
for (const dir of dirs) {
|
||||
currentPath = path.join(currentPath, dir)
|
||||
result.push({
|
||||
path: currentPath,
|
||||
type: 'directory',
|
||||
discovered: true,
|
||||
})
|
||||
}
|
||||
return {
|
||||
add: result,
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = handleCommand
|
||||
Reference in new issue
Block a user