Skip to content

Commit

Permalink
fix: key positions for sort command
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Mar 6, 2022
1 parent 67d316e commit 22ed6d2
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 126 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -10,13 +10,15 @@ jobs:
release:
environment: Release
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: "lts/*"
- run: npm ci
- run: npm run build
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -17,5 +17,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm test
4 changes: 1 addition & 3 deletions README.md
@@ -1,7 +1,5 @@
# Redis Commands

[![Build Status](https://github.com/ioredis/commands/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/ioredis/commands/actions/workflows/release.yml?query=branch%3Amain)

This module exports all the commands that Redis supports.

## Install
Expand All @@ -19,7 +17,7 @@ const commands = require('@ioredis/commands');
`.list` is an array contains all the lowercased commands:

```js
commands.list.forEach(function (command) {
commands.list.forEach((command) => {
console.log(command);
});
```
Expand Down
File renamed without changes.
9 changes: 5 additions & 4 deletions lib/index.ts
@@ -1,4 +1,4 @@
import commands from "../commands.json";
import commands from "./commands.json";

/**
* Redis command list
Expand Down Expand Up @@ -63,7 +63,7 @@ export function getKeyIndexes(
}

const keys = [];
const parseExternalKey = options && options.parseExternalKey;
const parseExternalKey = Boolean(options && options.parseExternalKey);

switch (commandName) {
case "zunionstore":
Expand All @@ -80,13 +80,14 @@ export function getKeyIndexes(
case "sort":
keys.push(0);
for (let i = 1; i < args.length - 1; i++) {
const arg = args[i];
let arg = args[i];
if (typeof arg !== "string") {
continue;
}
const directive = arg.toUpperCase();
if (directive === "GET") {
i += 1;
arg = args[i];
if (arg !== "#") {
if (parseExternalKey) {
keys.push([i, getExternalKeyNameLength(arg)]);
Expand All @@ -97,7 +98,7 @@ export function getKeyIndexes(
} else if (directive === "BY") {
i += 1;
if (parseExternalKey) {
keys.push([i, getExternalKeyNameLength(arg)]);
keys.push([i, getExternalKeyNameLength(args[i])]);
} else {
keys.push(i);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"pretest": "npm run lint",
"test": "mocha",
"build": "tsc",
"build": "rm -rf built && tsc",
"gen": "node tools/build",
"lint": "standard --fix --verbose | snazzy",
"release": "release-it"
Expand Down

0 comments on commit 22ed6d2

Please sign in to comment.