From 6d7181fe2b26e323ef0ad8261fe5eb00247a8134 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 20 Jun 2021 18:09:02 +0300 Subject: [PATCH] docs(user-menu-cookbook) files -> CurrentInfo.files --- User-Menu-Cookbook.md | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) 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