mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: static: user-menu: add recipes from Cookbook
This commit is contained in:
parent
1309d825e4
commit
8126b51831
2 changed files with 87 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const RENAME_FILE = 'Rename file';
|
||||
const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@';
|
||||
|
||||
module.exports = {
|
||||
'__settings': {
|
||||
|
|
@ -13,12 +14,45 @@ module.exports = {
|
|||
await DOM.renameCurrent();
|
||||
},
|
||||
|
||||
'F6 - Copy URL to current file': async ({DOM}) => {
|
||||
const {copyURLToCurrentFile} = await import(`${CDN}@1.1.0/menu/copy-url-to-current-file.js`);
|
||||
await copyURLToCurrentFile({DOM});
|
||||
},
|
||||
|
||||
'R - cd /': async ({CloudCmd}) => {
|
||||
await CloudCmd.changeDir('/');
|
||||
},
|
||||
'Y - Convert YouTube to MP3': async ({CloudCmd, DOM}) => {
|
||||
const {convertYouTubeToMp3} = await import(`${CDN}@v1.1.0/menu/convert-youtube-to-mp3.js`);
|
||||
await convertYouTubeToMp3({CloudCmd, DOM});
|
||||
},
|
||||
|
||||
'F - Convert flac to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => {
|
||||
const {convertFlacToMp3} = await import(`${CDN}@v1.1.0/menu/ffmpeg.js`);
|
||||
await convertFlacToMp3({CloudCmd, DOM});
|
||||
},
|
||||
'M - Convert mpeg to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => {
|
||||
const {convertMp4ToMp3} = await import(`${CDN}@v1.1.0/menu/ffmpeg.js`);
|
||||
await convertMp4ToMp3({CloudCmd, DOM});
|
||||
},
|
||||
|
||||
'C - Create User Menu File': async ({DOM, CloudCmd}) => {
|
||||
const {Dialog} = DOM;
|
||||
const currentFile = DOM.getCurrentByName('.cloudcmd.menu.js')
|
||||
|
||||
if (currentFile) {
|
||||
const [cancel] = await Dialog.confirm(`Looks like file '.cloudcmd.menu.js' already exists. Overwrite?`);
|
||||
|
||||
if (cancel)
|
||||
return;
|
||||
}
|
||||
|
||||
const {CurrentInfo} = DOM;
|
||||
const {dirPath} = CurrentInfo;
|
||||
const path = `${dirPath}.cloudcmd.menu.js`;
|
||||
const {prefix} = CloudCmd;
|
||||
|
||||
|
||||
const data = await readDefaultMenu({prefix});
|
||||
await createDefaultMenu({
|
||||
path,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ const defaultMenu = require('./user-menu');
|
|||
const test = autoGlobals(require('supertape'));
|
||||
|
||||
const {create} = autoGlobals;
|
||||
|
||||
const {_data} = defaultMenu;
|
||||
|
||||
const reject = wraptile(async (a) => {
|
||||
throw Error(a);
|
||||
});
|
||||
|
|
@ -29,6 +29,58 @@ test('cloudcmd: static: user menu: Rename', async (t) => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: R', (t) => {
|
||||
const name = 'R - cd /';
|
||||
const changeDir = stub();
|
||||
const CloudCmd = {
|
||||
changeDir,
|
||||
};
|
||||
|
||||
const fn = defaultMenu[name];
|
||||
fn({
|
||||
CloudCmd,
|
||||
});
|
||||
|
||||
t.calledWith(changeDir, ['/']);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: F6', (t) => {
|
||||
const name = 'F6 - Copy URL to current file';
|
||||
|
||||
const fn = defaultMenu[name];
|
||||
|
||||
t.ok(fn);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: Y', (t) => {
|
||||
const name = 'Y - Convert YouTube to MP3';
|
||||
|
||||
const fn = defaultMenu[name];
|
||||
|
||||
t.ok(fn);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: F', (t) => {
|
||||
const name = 'F - Convert flac to mp3 [ffmpeg]';
|
||||
|
||||
const fn = defaultMenu[name];
|
||||
|
||||
t.ok(fn);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: M', (t) => {
|
||||
const name = 'M - Convert mpeg to mp3 [ffmpeg]';
|
||||
|
||||
const fn = defaultMenu[name];
|
||||
|
||||
t.ok(fn);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: IO.write', async (t) => {
|
||||
const name = 'C - Create User Menu File';
|
||||
const DOM = getDOM();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue