From 6d076c617509d4e8ce32bc372ec92637fd657306 Mon Sep 17 00:00:00 2001 From: Patrick Low Date: Thu, 25 Jun 2020 18:12:49 +0800 Subject: [PATCH 1/2] add compare ts --- src/compare.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/compare.ts diff --git a/src/compare.ts b/src/compare.ts new file mode 100644 index 00000000..11d0f0fc --- /dev/null +++ b/src/compare.ts @@ -0,0 +1,31 @@ +import commander from 'commander' +import { readFileSync, existsSync, writeFileSync } from 'fs' +import { resolve, join, dirname } from 'path' +import { tempdir } from 'shelljs' +import toHtml from 'hast-util-to-html' +import * as Hast from 'hast' +import * as Hast$ from 'hast-util-select' +import remove from 'unist-util-remove' +import open from 'open' +import { store, Selector, Action } from './store' +import { register } from './register' + +commander.version('1.0.0').usage('[command] [options]') + +commander + .command('get:pages') + .description('Get Pages and write in "learnk8s-pages-state.json"') + .action(() => { + register(store) + const pages = Selector.pages.selectAll(store.getState()) + const tmpFolder = tempdir() + const jsonPath = join(tmpFolder, `learnk8s-pages-state.json`) + writeFileSync(jsonPath, JSON.stringify(pages)) + console.log(`Created ${jsonPath}!`) + }) + +commander.parse(process.argv) + +if (commander.args.length === 0) { + commander.help() +} From ae16e6f5b27df062068326a1d85091db6654c5fc Mon Sep 17 00:00:00 2001 From: Patrick Low Date: Fri, 26 Jun 2020 15:40:03 +0800 Subject: [PATCH 2/2] lint --- src/compare.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/compare.ts b/src/compare.ts index 11d0f0fc..1efda262 100644 --- a/src/compare.ts +++ b/src/compare.ts @@ -1,13 +1,8 @@ import commander from 'commander' -import { readFileSync, existsSync, writeFileSync } from 'fs' -import { resolve, join, dirname } from 'path' +import { writeFileSync } from 'fs' +import { join } from 'path' import { tempdir } from 'shelljs' -import toHtml from 'hast-util-to-html' -import * as Hast from 'hast' -import * as Hast$ from 'hast-util-select' -import remove from 'unist-util-remove' -import open from 'open' -import { store, Selector, Action } from './store' +import { store, Selector } from './store' import { register } from './register' commander.version('1.0.0').usage('[command] [options]')