diff --git a/User-Menu-Cookbook.md b/User-Menu-Cookbook.md index ed2153e..c0568dd 100644 --- a/User-Menu-Cookbook.md +++ b/User-Menu-Cookbook.md @@ -37,8 +37,6 @@ export default { Simple example of running bash scripts with help of `TerminalRun`. ```js -'use strict'; - const isMp3 = (a) => /\.mp3$/.test(a); export default { @@ -46,8 +44,7 @@ export default { const {IO, CurrentInfo} = DOM; const root = CloudCmd.config('root'); - const {dirPath, files} = CurrentInfo; - const cwd = `${root}${dirPath}`; + const cwd = `${root}${CurrentInfo.dirPath}`; const convert = 'for f in *.flac; do ffmpeg -vsync 2 -i "$f" -b:a 320k "${f%flac}mp3"; done'; const exitCode = await CloudCmd.TerminalRun.show({ @@ -58,37 +55,18 @@ export default { if (exitCode) return; + await IO.createDirectory('/mp3'); await CloudCmd.refresh(); - const mp3Dir = `${cwd}mp3`; - - const names = DOM.getFilenames(files); + const names = DOM.getFilenames(CurrentInfo.files); const mp3Names = names.filter(isMp3); - await IO.createDirectory(mp3Dir); - await IO.move(dirPath, mp3Dir, mp3Names); + const mp3Dir = `${cwd}/mp3`; + await IO.move(cwd, mp3Dir, mp3Names); await CloudCmd.refresh(); }, }; - -async function createDefaultMenu({path, data, DOM, CloudCmd}) { - const {IO} = DOM; - - await IO.write(path, data); - await CloudCmd.refresh(); - - DOM.setCurrentByName('.cloudcmd.menu.js'); - - await CloudCmd.EditFile.show(); -} - -async function readDefaultMenu({prefix}) { - const res = await fetch(`${prefix}/api/v1/user-menu/default`); - const data = await res.text(); - - return data; -} ``` ## Create User Menu File