Skip to content

Commit

Permalink
Merge pull request #2 from hidetak/develop
Browse files Browse the repository at this point in the history
sjis character output for windows
  • Loading branch information
hidetak authored Mar 7, 2020
2 parents 51bd6e2 + 4bf141c commit ca8ef37
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
17 changes: 14 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const readLine = require('readline')
const fetch = require('node-fetch')
const moment = require('moment-timezone')
const Iconv = require('iconv').Iconv

if (process.argv.length !== 5) {
console.error(
Expand All @@ -22,6 +23,14 @@ const ACTIONS_URL = `https://trello.com/1/cards/$$CARD_ID$$/actions?key=${KEY}&t
// Debugの出力を抑止
console.debug = () => {}

// OSの取得
const isWindows = process.platform === 'win32'
const isMac = process.platform === 'darwin'
const isLinux = process.platform === 'linux'

// 文字コード変換の準備
const iconv = new Iconv('UTF-8', 'SHIFT_JIS//IGNORE')

const readUserInput = (question, initialInput) => {
const rl = readLine.createInterface({
input: process.stdin,
Expand Down Expand Up @@ -62,9 +71,11 @@ const writeLine = d => {
let outDate = moment(d.outDate)
.tz('Asia/Tokyo')
.format('YYYY/MM/DD HH:mm:ss')
console.log(
`"${d.cardId}","${d.number}","${d.title}","${d.point}","${d.listName}","${inDate}","${outDate}","${d.time}","${d.labelPink}","${d.labelGreen}","${d.member}"`
)
let line = `"${d.cardId}","${d.number}","${d.title}","${d.point}","${d.listName}","${inDate}","${outDate}","${d.time}","${d.labelPink}","${d.labelGreen}","${d.member}"`
if (isWindows) {
line = iconv.convert(line).toString()
}
console.log(line)
}

const parseData = (actionMap, cardsMap) => {
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trello-csv",
"version": "0.0.1",
"version": "0.0.2",
"description": "",
"main": "index.js",
"scripts": {
Expand All @@ -10,6 +10,7 @@
"author": "hidetak",
"license": "ISC",
"dependencies": {
"iconv": "^2.3.5",
"moment": "^2.24.0",
"moment-timezone": "^0.5.28",
"node-fetch": "^2.6.0"
Expand Down

0 comments on commit ca8ef37

Please sign in to comment.