diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index faed5259..1d16cdb1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,12 +8,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 with: bun-version: latest - name: Use Node.js 16.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16.x - name: Install Redrun diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c49d3c3b..691f1b77 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -12,13 +12,14 @@ jobs: - 16.x - 18.x - 20.x + - 21.x steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 with: bun-version: latest - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Install Redrun diff --git a/.putout.json b/.putout.json index c746c016..801301d1 100644 --- a/.putout.json +++ b/.putout.json @@ -16,11 +16,8 @@ "route.spec.js": { "tape/convert-ok-to-match": "off" }, - "*.js": { - "convert-esm-to-commonjs": "on" - }, "*.md": { - "convert-commonjs-to-esm": "on" + "nodejs/convert-commonjs-to-esm": "on" }, ".webpack": { "webpack": "on" diff --git a/client/key/index.js b/client/key/index.js index 6fe55307..e7078e16 100644 --- a/client/key/index.js +++ b/client/key/index.js @@ -19,9 +19,8 @@ const Chars = fullstore(); const toggleVim = (keyCode) => { const {_config, config} = CloudCmd; - if (keyCode === KEY.ESC) { + if (keyCode === KEY.ESC) _config('vim', !config('vim')); - } }; const isUndefined = (a) => typeof a === 'undefined'; diff --git a/client/listeners/index.js b/client/listeners/index.js index dab178e3..db927833 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -178,7 +178,8 @@ function decodePath(path) { const {prefix} = CloudCmd; const prefixReg = RegExp('^' + prefix + FS); - return decodeURI(path).replace(url, '') + return decodeURI(path) + .replace(url, '') .replace(prefixReg, '') // browser doesn't replace % -> %25% do it for him .replace('%%', '%25%') .replace(NBSP_REG, SPACE) || '/'; diff --git a/client/modules/command-line.js b/client/modules/command-line.js index a6cbf231..a0c000d9 100644 --- a/client/modules/command-line.js +++ b/client/modules/command-line.js @@ -16,9 +16,8 @@ async function show() { const [, cmd] = await Dialog.prompt('Command Line', ''); const TERMINAL = '^(t|terminal)'; - if (RegExp(`${TERMINAL}$`).test(cmd)) { + if (RegExp(`${TERMINAL}$`).test(cmd)) return await CloudCmd.Terminal.show(); - } if (RegExp(TERMINAL).test(cmd)) { const command = cmd.replace(RegExp(`${TERMINAL} `), ''); diff --git a/client/modules/terminal-run.js b/client/modules/terminal-run.js index f9001650..01bd30a9 100644 --- a/client/modules/terminal-run.js +++ b/client/modules/terminal-run.js @@ -123,9 +123,8 @@ function create(createOptions) { if (commandExit) hide(); - if (shiftKey && keyCode === Key.ESC) { + if (shiftKey && keyCode === Key.ESC) hide(); - } }); Socket.on('exit', (code) => { diff --git a/client/modules/terminal.js b/client/modules/terminal.js index 8f0c97de..f94024d4 100644 --- a/client/modules/terminal.js +++ b/client/modules/terminal.js @@ -90,9 +90,8 @@ function create() { Terminal.onKey(({domEvent}) => { const {keyCode, shiftKey} = domEvent; - if (shiftKey && keyCode === Key.ESC) { + if (shiftKey && keyCode === Key.ESC) hide(); - } }); Socket.on('connect', exec.with(authCheck, socket)); diff --git a/client/modules/user-menu/navigate.js b/client/modules/user-menu/navigate.js index 2f0833d4..445d47d1 100644 --- a/client/modules/user-menu/navigate.js +++ b/client/modules/user-menu/navigate.js @@ -13,9 +13,8 @@ const store = fullstore(1); const isDigit = (a) => /^\d+$/.test(a); module.exports = (el, {key, keyCode}) => { - if (isDigit(key)) { + if (isDigit(key)) store(Number(key)); - } if (keyCode === DOWN || keyCode === J) { const count = store(); diff --git a/client/modules/user-menu/parse-user-menu.js b/client/modules/user-menu/parse-user-menu.js index 2a947f83..f97cc109 100644 --- a/client/modules/user-menu/parse-user-menu.js +++ b/client/modules/user-menu/parse-user-menu.js @@ -14,9 +14,8 @@ module.exports = (userMenu) => { continue; } - if (str.startsWith('_')) { + if (str.startsWith('_')) continue; - } names.push(str); const [key, name] = str.split(' - '); diff --git a/client/sort.js b/client/sort.js index 7c5b7330..fdcfaf65 100644 --- a/client/sort.js +++ b/client/sort.js @@ -16,14 +16,12 @@ const {getPanel} = DOM; CloudCmd.sortPanel = (name, panel = getPanel()) => { const position = panel.dataset.name.replace('js-', ''); - if (name !== sortPrevious) { + if (name !== sortPrevious) + order[position] = 'asc'; + else if (order[position] === 'asc') + order[position] = 'desc'; + else order[position] = 'asc'; - } else { - if (order[position] === 'asc') - order[position] = 'desc'; - else - order[position] = 'asc'; - } sortPrevious = sort[position] = name; diff --git a/common/util.js b/common/util.js index 2e6b330a..f3e00465 100644 --- a/common/util.js +++ b/common/util.js @@ -17,7 +17,6 @@ module.exports.escapeRegExp = (str) => { */ module.exports.getRegExp = (wildcard) => { const escaped = `^${wildcard // search from start of line - .replace(/\./g, '\\.') .replace(/\*/g, '.*') .replace('?', '.?')}$`; diff --git a/server/distribute/import.js b/server/distribute/import.js index 5a665b04..7a88e89d 100644 --- a/server/distribute/import.js +++ b/server/distribute/import.js @@ -60,9 +60,8 @@ const emitAuth = wraptile((importUrl, config, socket) => { const updateConfig = currify((config, data) => { for (const [key, value] of entries(data)) { - if (typeof env(key) !== 'undefined') { + if (typeof env(key) !== 'undefined') continue; - } config(key, value); } diff --git a/test/common/cloudfunc.js b/test/common/cloudfunc.js index 3acfd768..f1365ee3 100644 --- a/test/common/cloudfunc.js +++ b/test/common/cloudfunc.js @@ -82,9 +82,8 @@ test('cloudfunc: render', (t) => { .some((item, number) => { const ret = result[number] !== item; - if (ret) { + if (ret) i = number; - } return ret; });