mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-17 16:38:18 +00:00
feature: client: listeners: migrate to ESM
This commit is contained in:
parent
091f901789
commit
f849b8423d
8 changed files with 26 additions and 40 deletions
|
|
@ -8,7 +8,7 @@ import Util from '../common/util.js';
|
|||
import * as CloudFunc from '../common/cloudfunc.mjs';
|
||||
import DOM from './dom/index.js';
|
||||
import {createCloudCmd} from './client.mjs';
|
||||
import * as Listeners from './listeners/index.js';
|
||||
import * as Listeners from './listeners/index.mjs';
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ const {
|
|||
setCurrent,
|
||||
selectFileNotParent,
|
||||
} = require('./set-current');
|
||||
const {promptNewFile} = require('../../dom');
|
||||
|
||||
module.exports = (key, event, overrides = {}) => {
|
||||
const defaults = {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
'use strict';
|
||||
import currify from 'currify';
|
||||
|
||||
module.exports = (array, item) => {
|
||||
export const getIndex = currify((array, item) => {
|
||||
const index = array.indexOf(item);
|
||||
|
||||
if (!~index)
|
||||
return 0;
|
||||
|
||||
return index;
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('supertape');
|
||||
|
||||
const dir = '../../../client/listeners';
|
||||
const getIndex = require(`${dir}/get-index`);
|
||||
import test from 'supertape';
|
||||
import {getIndex} from './get-index.mjs';
|
||||
|
||||
test('cloudcmd: client: listeners: getIndex: not found', (t) => {
|
||||
const array = ['hello'];
|
||||
|
|
@ -21,3 +17,4 @@ test('cloudcmd: client: listeners: getIndex: found', (t) => {
|
|||
t.equal(getIndex(array, 'world'), 1, 'should return index');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = (indexFrom, indexTo, files) => {
|
||||
export const getRange = (indexFrom, indexTo, files) => {
|
||||
if (indexFrom < indexTo)
|
||||
return files.slice(indexFrom, indexTo + 1);
|
||||
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('supertape');
|
||||
|
||||
const dir = '../../../client/listeners';
|
||||
const getRange = require(`${dir}/get-range`);
|
||||
import test from 'supertape';
|
||||
import {getRange} from './get-range.mjs';
|
||||
|
||||
test('cloudcmd: client: listeners: getRange: direct', (t) => {
|
||||
const expected = [
|
||||
|
|
@ -54,3 +50,4 @@ test('cloudcmd: client: listeners: getRange: one', (t) => {
|
|||
t.deepEqual(result, expected, 'should return range');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -1,24 +1,19 @@
|
|||
/* global DOM, CloudCmd */
|
||||
|
||||
'use strict';
|
||||
|
||||
const exec = require('execon');
|
||||
const itype = require('itype');
|
||||
const currify = require('currify');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const clipboard = require('@cloudcmd/clipboard');
|
||||
|
||||
const getRange = require('./get-range');
|
||||
const uploadFiles = require('../dom/upload-files');
|
||||
const {FS} = require('../../common/cloudfunc.mjs');
|
||||
const Events = require('#dom/events');
|
||||
|
||||
const getIndex = currify(require('./get-index'));
|
||||
import exec from 'execon';
|
||||
import itype from 'itype';
|
||||
import currify from 'currify';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import clipboard from '@cloudcmd/clipboard';
|
||||
import * as Events from '#dom/events';
|
||||
import {getRange} from './get-range.mjs';
|
||||
import uploadFiles from '../dom/upload-files.js';
|
||||
import {FS} from '../../common/cloudfunc.mjs';
|
||||
import {getIndex} from './get-index.mjs';
|
||||
|
||||
const NBSP_REG = RegExp(String.fromCharCode(160), 'g');
|
||||
const SPACE = ' ';
|
||||
|
||||
module.exports.init = async () => {
|
||||
export const init = async () => {
|
||||
contextMenu();
|
||||
dragndrop();
|
||||
unload();
|
||||
|
|
@ -99,7 +94,7 @@ async function config() {
|
|||
EXT = DOM.getPackerExt(type);
|
||||
}
|
||||
|
||||
module.exports.initKeysPanel = () => {
|
||||
export const initKeysPanel = () => {
|
||||
const keysElement = DOM.getById('js-keyspanel');
|
||||
|
||||
if (!keysElement)
|
||||
|
|
@ -145,7 +140,7 @@ const getPanel = (side) => {
|
|||
return DOM.getByDataName(`js-${side}`);
|
||||
};
|
||||
|
||||
module.exports.setOnPanel = (side) => {
|
||||
export const setOnPanel = (side) => {
|
||||
const panel = getPanel(side);
|
||||
|
||||
const filesElement = DOM.getByDataName('js-files', panel);
|
||||
|
|
@ -500,4 +495,3 @@ function resize() {
|
|||
DOM.changePanel();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ export const match = {
|
|||
'client/dom/index.js': {
|
||||
'no-multi-spaces': 'off',
|
||||
},
|
||||
'{client,static}/**/*.js': {
|
||||
'{client,static}/**/*.{js,mjs}': {
|
||||
'n/no-extraneous-require': 'off',
|
||||
'n/no-unsupported-features/node-builtins': 'off',
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue