chore(client) convert to esm

This commit is contained in:
coderaiser 2020-12-24 19:06:35 +02:00
parent d475790257
commit 18dc5d3a4c
91 changed files with 587 additions and 805 deletions

View file

@ -1,6 +1,4 @@
'use strict';
module.exports = (operation, from, to) => {
export default (operation, from, to) => {
if (!to)
return `${operation} ${from}`;

View file

@ -1,11 +1,9 @@
'use strict';
const currify = require('currify');
import currify from 'currify';
const not = currify((array, value) => !array.includes(value));
const notOneOf = currify((a, b) => a.filter(not(b)));
module.exports = (currentName, names, removedNames) => {
export default (currentName, names, removedNames) => {
const i = names.indexOf(currentName);
const nextNames = notOneOf(names, removedNames);

View file

@ -3,25 +3,20 @@
/* global DOM */
/* global fileop */
'use strict';
import currify from 'currify';
import wraptile from 'wraptile';
import {promisify} from 'es6-promisify';
import exec from 'execon';
import load from 'load.js';
import tryToCatch from 'try-to-catch';
const currify = require('currify');
const wraptile = require('wraptile');
const {promisify} = require('es6-promisify');
const exec = require('execon');
const load = require('load.js');
const tryToCatch = require('try-to-catch');
const {encode} = require('../../../common/entity');
const removeExtension = require('./remove-extension');
const setListeners = require('./set-listeners');
const getNextCurrentName = require('./get-next-current-name');
import {encode} from '../../../common/entity.js';
import removeExtension from './remove-extension.js';
import setListeners from './set-listeners.js';
import getNextCurrentName from './get-next-current-name.js';
const removeQuery = (a) => a.replace(/\?.*/, '');
const Name = 'Operation';
CloudCmd[Name] = exports;
const {config} = CloudCmd;
const {Dialog, Images} = DOM;
@ -52,7 +47,7 @@ const noFilesCheck = () => {
return is;
};
module.exports.init = promisify((callback) => {
export const init = promisify((callback) => {
showLoad();
exec.series([
@ -77,6 +72,12 @@ module.exports.init = promisify((callback) => {
], callback);
});
CloudCmd.Operation = {
init,
show,
hide,
};
function _authCheck(spawn, ok) {
const accept = wraptile(ok);
const alertDialog = wraptile(Dialog.alert);
@ -190,11 +191,11 @@ function getPacker(type) {
return packTarFn;
}
module.exports.hide = () => {
export function hide() {
CloudCmd.View.hide();
};
}
module.exports.show = (operation, data) => {
export function show(operation, data) {
if (!Loaded)
return;
@ -215,7 +216,7 @@ module.exports.show = (operation, data) => {
if (operation === 'extract')
return Operation.extract();
};
}
Operation.copy = processFiles({
type: 'copy',

View file

@ -1,8 +1,6 @@
'use strict';
import {getExt} from '../../../common/util.js';
const {getExt} = require('../../../common/util');
module.exports = (name) => {
export default (name) => {
const ext = getExtension(name);
return name.replace(ext, '');

View file

@ -1,7 +1,5 @@
'use strict';
const test = require('supertape');
const removeExtension = require(`./remove-extension`);
import test from 'supertape';
import removeExtension from './remove-extension.js';
test('cloudcmd: client: modules: operation: removeExtension: .tar.gz', (t) => {
const name = 'hello';

View file

@ -1,5 +1,3 @@
'use strict';
/* global DOM */
const {
@ -7,12 +5,12 @@ const {
Images,
} = DOM;
const forEachKey = require('for-each-key');
const wraptile = require('wraptile');
import forEachKey from 'for-each-key';
import wraptile from 'wraptile';
const format = require('./format');
import format from './format.js';
module.exports = (options) => (emitter) => {
export default (options) => (emitter) => {
const {
operation,
callback,