From c399f8160e865844fe4f1dfbe61f78095e9a8cf8 Mon Sep 17 00:00:00 2001 From: cboyce183 Date: Thu, 24 Mar 2022 13:21:32 +0000 Subject: [PATCH 1/5] feat: fileType flag pixo fork noissue --- bin/cli.js | 22 +++++++++++++++++++++- package.json | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 3b0c140..ca535e6 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -31,6 +31,10 @@ const cli = meow(` `, { booleanDefault: undefined, flags: { + fileType: { + type: 'string', + alias: 'f' + }, outDir: { type: 'string', alias: 'd' @@ -93,6 +97,22 @@ const readFile = file => { const ignore = (file, stats) => !stats.isDirectory() && !/\.svg$/.test(file) +const validateFileType = { + '.js': '.js', + 'js': '.js', + 'javascript': '.js', + + 'jsx': '.jsx', + '.jsx': '.jsx', + + 'ts': '.ts', + '.ts': '.ts', + 'typescript': '.ts', + + 'tsx': 'tsx', + '.tsx': '.tsx' +} + const convert = async (opts) => { const readdir = opts.recursive ? async dirname => recursiveReaddir(dirname, [ ignore ]) @@ -113,7 +133,7 @@ const convert = async (opts) => { fs.mkdirSync(opts.outDir) } components.forEach(({ name, content }) => { - const filename = path.join(opts.outDir, name + '.js') + const filename = path.join(opts.outDir, name + (validateFileType[opts.fileType] || '.js')) fs.writeFileSync(filename, content) }) } diff --git a/package.json b/package.json index ba79b1f..dba2bcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixo", - "version": "1.1.2", + "version": "1.1.3", "description": "Convert SVG icons into React components", "main": "index.js", "bin": { From d12705ab007d3276d4f3e8adaa6280c56dbad254 Mon Sep 17 00:00:00 2001 From: cboyce183 Date: Thu, 24 Mar 2022 13:32:14 +0000 Subject: [PATCH 2/5] feat: update readme noissue --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b35b4d5..c65ce6d 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ Run `pixo --help` to see the list of options. -i --index Include index.js barrel module -c --icon-component Include wrapper Icon.js component -r --recursive Recursively read all SVGs in subdirectories +-f --fileType Specify JavaScript/jsx or TypeScript/tsx by name or extension. Default JavaScript. ``` **Example `package.json`** From 5d05ab0ad571dc28b82925ec03b93e32134d41f1 Mon Sep 17 00:00:00 2001 From: Charles Boyce <31250541+cboyce183@users.noreply.github.com> Date: Thu, 24 Mar 2022 13:35:35 +0000 Subject: [PATCH 3/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c65ce6d..60a6b4f 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ Run `pixo --help` to see the list of options. - `index` (boolean) create an `index.js` barrel module - `iconComponent` (boolean) create an `Icon.js` wrapper component - `recursive` (boolean) recursively read all SVGs in subdirectories +- `fileType` (string) Specifies a file type to output all generated SVGs, defaulting to .js **CLI flags** From 2efb777d50ece4c57fbd5eade3ab33e406187f4e Mon Sep 17 00:00:00 2001 From: Charles Boyce <31250541+cboyce183@users.noreply.github.com> Date: Thu, 24 Mar 2022 13:56:32 +0000 Subject: [PATCH 4/5] fix: important missing period noissue --- bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index ca535e6..037bb76 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -109,7 +109,7 @@ const validateFileType = { '.ts': '.ts', 'typescript': '.ts', - 'tsx': 'tsx', + 'tsx': '.tsx', '.tsx': '.tsx' } From f0edb5a0bca68529352a0f8f4e6fac1f6ffc4384 Mon Sep 17 00:00:00 2001 From: Charles Boyce <31250541+cboyce183@users.noreply.github.com> Date: Thu, 24 Mar 2022 13:57:07 +0000 Subject: [PATCH 5/5] feat: bump version noissue --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dba2bcc..8cfc854 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pixo", - "version": "1.1.3", + "version": "1.1.4", "description": "Convert SVG icons into React components", "main": "index.js", "bin": {