From d6273743135c2e9298335f76071d5745c05fa77c Mon Sep 17 00:00:00 2001 From: Kodai Aoyama Date: Sat, 26 Mar 2022 22:50:14 +0900 Subject: [PATCH] fix colc cannot analyse tsv --- README.md | 2 +- colc.ts | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 04362cf..0e3934e 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ you can download a binary release ```sh # Install with wget or curl ## set the latest version on releases. -VERSION=v1.0.7 +VERSION=v1.0.8 ## case you use wget wget https://github.com/solaoi/colc/releases/download/$VERSION/colc_linux_amd64.tar.gz ## case you use curl diff --git a/colc.ts b/colc.ts index 1408847..44f2149 100644 --- a/colc.ts +++ b/colc.ts @@ -21,7 +21,7 @@ const binSize: number | null = (() => { const isCsv = filename.endsWith(".csv"); const headerName = await runner.run( - `head -n 1 ${filename}| cut -f${column} ${isCsv && "-d, "}| tr -d 0-9.-`, + `head -n 1 ${filename}| cut -f${column} ${isCsv ? "-d, " : ""}| tr -d 0-9.-`, ); const hasHeader = headerName !== ""; @@ -29,10 +29,12 @@ if (binSize === null) { const statsCommand = (() => { const bash = []; if (hasHeader) { - bash.push(`tail -n +2 ${filename} | cut -f${column} ${isCsv && "-d, "}`); + bash.push( + `tail -n +2 ${filename} | cut -f${column} ${isCsv ? "-d, " : ""}`, + ); } else { bash.push( - `cut -f${column} ${isCsv && "-d, "}${filename} `, + `cut -f${column} ${isCsv ? "-d, " : ""}${filename} `, ); } bash.push("| sort -n | awk"); @@ -78,10 +80,12 @@ if (binSize === null) { const freqCommand = (() => { const bash = []; if (hasHeader) { - bash.push(`tail -n +2 ${filename} | cut -f${column} ${isCsv && "-d, "}`); + bash.push( + `tail -n +2 ${filename} | cut -f${column} ${isCsv ? "-d, " : ""}`, + ); } else { bash.push( - `cut -f${column} ${isCsv && "-d, "}${filename} `, + `cut -f${column} ${isCsv ? "-d, " : ""}${filename} `, ); } bash.push("| awk");