From 15c017bc5b5fad6ad5ddcf488e99d2928e5b9ac5 Mon Sep 17 00:00:00 2001 From: Garrett Luu Date: Wed, 24 Jun 2020 12:40:26 -0700 Subject: [PATCH] CLI refactor * Moved cli to packages/ssf-cli * Modified bin in package.json files --- bin/ssf.njs | 13 ------------- package.json | 3 --- packages/ssf-cli/.gitignore | 1 + packages/ssf-cli/bin/ssf.njs | 8 ++++++++ packages/ssf-cli/index.js | 17 +++++++++++++++++ packages/ssf-cli/package.json | 14 ++++++++++++++ 6 files changed, 40 insertions(+), 16 deletions(-) delete mode 100755 bin/ssf.njs create mode 100644 packages/ssf-cli/.gitignore create mode 100755 packages/ssf-cli/bin/ssf.njs create mode 100644 packages/ssf-cli/index.js create mode 100644 packages/ssf-cli/package.json diff --git a/bin/ssf.njs b/bin/ssf.njs deleted file mode 100755 index 79610a5..0000000 --- a/bin/ssf.njs +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node -/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */ -/* eslint-env node */ -/* eslint no-console:0 */ -/*jshint node:true */ -var X = require('../'); -var argv = process.argv.slice(2); -if(argv.length < 2 || argv[0] == "-h" || argv[0] == "--help") { - console.error("usage: ssf "); - console.error("output: format_as_string|format_as_number|"); - process.exit(0); -} -console.log(X.format(argv[0],argv[1]) + "|" + X.format(argv[0],+(argv[1])) + "|"); diff --git a/package.json b/package.json index df0e1ac..b8b8c5c 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,6 @@ "sprintf", "spreadsheet" ], - "bin": { - "ssf": "./bin/ssf.njs" - }, "main": "./ssf", "types": "types", "dependencies": { diff --git a/packages/ssf-cli/.gitignore b/packages/ssf-cli/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/packages/ssf-cli/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/packages/ssf-cli/bin/ssf.njs b/packages/ssf-cli/bin/ssf.njs new file mode 100755 index 0000000..a05f4f7 --- /dev/null +++ b/packages/ssf-cli/bin/ssf.njs @@ -0,0 +1,8 @@ +#!/usr/bin/env node +/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */ +/* eslint-env node */ +/* eslint no-console:0 */ +/*jshint node:true */ +var cli = require('../'); + +cli(); \ No newline at end of file diff --git a/packages/ssf-cli/index.js b/packages/ssf-cli/index.js new file mode 100644 index 0000000..12e78ed --- /dev/null +++ b/packages/ssf-cli/index.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node +/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */ +/* eslint-env node */ +/* eslint no-console:0 */ +/*jshint node:true */ +var X = require('ssf'); +function run() { + var argv = process.argv.slice(2); + if (argv.length < 2 || argv[0] == "-h" || argv[0] == "--help") { + console.error("usage: ssf "); + console.error("output: format_as_string|format_as_number|"); + process.exit(0); + } + console.log(X.format(argv[0], argv[1]) + "|" + X.format(argv[0], +(argv[1])) + "|"); +} + +module.exports = run; \ No newline at end of file diff --git a/packages/ssf-cli/package.json b/packages/ssf-cli/package.json new file mode 100644 index 0000000..40d2291 --- /dev/null +++ b/packages/ssf-cli/package.json @@ -0,0 +1,14 @@ +{ + "name": "ssf-cli", + "version": "1.0.0", + "description": "Command-line interface for ssf", + "bin": { + "ssf-cli": "./bin/ssf.njs" + }, + "main": "index.js", + "author": "Garrett Luu", + "license": "Apache-2.0", + "dependencies": { + "ssf": "^0.11.1" + } +}