diff --git a/.gitignore b/.gitignore index 700003d..9bfa834 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ node_modules /.idea cdt.iml **/.DS_Store +output/* +!output/.gitkeep diff --git a/src/commands/hash.ts b/src/commands/hash.ts index 610d48a..1e0d696 100644 --- a/src/commands/hash.ts +++ b/src/commands/hash.ts @@ -16,7 +16,7 @@ export default class Hash extends Command { type: flags.string({char: 't' , description: 'type of hash [SHA1(default), MD5, SHA256, SHA512, RMD160 or RIPEMD160]'}), string: flags.string({char: 's' , description: 'string to be hashed'}), file: flags.string({char: 'f' , description: 'file to be hashed'}), - outputFile: flags.string({char: 'o' , description: 'output file path'}), + output: flags.string({char: 'o' , description: 'output file path'}), } static args = [{name: 'string'}] @@ -47,8 +47,8 @@ export default class Hash extends Command { let hashed: string = hashObject(args.string) Logger.success(this, `[${flags.type.toUpperCase()}] ${hashed}`) - if (flags.outputFile) { // if output path is provided then write to file also - Utilities.writeStringToFile(this, flags.outputFile, hashed) + if (flags.output) { // if output path is provided then write to file also + Utilities.writeStringToFile(this, flags.output, hashed) } } diff --git a/src/commands/minify.ts b/src/commands/minify.ts index a3f99ea..53d14e4 100644 --- a/src/commands/minify.ts +++ b/src/commands/minify.ts @@ -12,7 +12,7 @@ export default class Minify extends Command { help: flags.help({char: 'h'}), type: flags.string({char: 't' , description: 'type of file to be minified, it will try to find type with extension supported: JS, HTML/HTM, CSS'}), file: flags.string({char: 'f' , description: 'file to be minified'}), - outputFile: flags.string({char: 'o' , description: 'output file path'}), + output: flags.string({char: 'o' , description: 'output file path'}), } static args = [{name: 'file'}] @@ -100,8 +100,8 @@ export default class Minify extends Command { Logger.progressStop(this, `file: ${flags.file} minified`) // }, 1000) - if (flags.outputFile) { // if output path is provided then write to file also - Utilities.writeStringToFile(this, flags.outputFile, output) + if (flags.output) { // if output path is provided then write to file also + Utilities.writeStringToFile(this, flags.output, output) } else Logger.success(this, `minified output: \n${output}`) } diff --git a/test/commands/hash.test.ts b/test/commands/hash.test.ts index 8401112..99b8fd0 100644 --- a/test/commands/hash.test.ts +++ b/test/commands/hash.test.ts @@ -2,7 +2,7 @@ import {expect, test} from '@oclif/test' describe('hash', () => { test - .timeout(10000) // added timeout to resolve timeout problem + .timeout(20000) // added timeout to resolve timeout problem .stdout() .command(['hash', 'ashish']) .it("Check default type -> cdt hash 'ashish'", ctx => { @@ -107,6 +107,13 @@ describe('hash', () => { expect(ctx.stdout).to.contain('4493b97b4a0d21fc561070c48d4a62a9bfbeb78c5d9b3c59abf6d41f70da2e9bd45af63d8c62812cf41e50e352ec41b4f407f71d5778b575c503b70081e7a151') }) + test + .stdout() + .command(['hash', '-f', 'test/resources/test.txt', '-t', 'sha512', '--output', 'test/resources/output/out.txt']) + .it("File Hashing, output to a file", ctx => { + expect(ctx.stdout).to.contain('✔ success output written to file') + }) + //file input - file not found test .stdout() diff --git a/test/commands/minify.test.ts b/test/commands/minify.test.ts index bc295c1..4fc8486 100644 --- a/test/commands/minify.test.ts +++ b/test/commands/minify.test.ts @@ -2,6 +2,7 @@ import {expect, test} from '@oclif/test' describe('minify', () => { test + .timeout(20000) // added timeout to resolve timeout problem .stdout() .command(['minify', '-t', 'js']) .exit(0) @@ -46,4 +47,10 @@ describe('minify', () => { expect(ctx.stdout).to.contain('body{margin:25px;background-color:#f0f0f0;font-family:arial,sans-serif;font-size:14px}h1{font-size:35px;font-weight:400;margin-top:5px}.someclass{color:red}#someid{color:green}') }) + test + .stdout() + .command(['minify', '-f', 'test/resources/test.css', '--output', 'test/resources/output/ouput.css']) + .it('Minify CSS, output to a file', ctx => { + expect(ctx.stdout).to.contain('✔ success output written to file') + }) }) diff --git a/test/resources/avro/output/.gitkeep b/test/resources/avro/output/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/resources/avro/output/output_complex.avsc b/test/resources/avro/output/output_complex.avsc deleted file mode 100644 index 538168d..0000000 --- a/test/resources/avro/output/output_complex.avsc +++ /dev/null @@ -1,80 +0,0 @@ -{ - "name": "example.avro.Complex", - "type": "record", - "fields": [ - { - "name": "stringArray", - "type": { - "type": "array", - "items": "string" - } - }, - { - "name": "longArray", - "type": { - "type": "array", - "items": "long" - } - }, - { - "name": "enumField", - "type": { - "name": "example.avro.foo", - "type": "enum", - "symbols": [ - "A", - "B", - "C", - "D" - ] - } - }, - { - "name": "mapOfInts", - "type": { - "type": "map", - "values": "int" - } - }, - { - "name": "unionField", - "type": [ - "null", - "string" - ] - }, - { - "name": "fixedField", - "type": { - "name": "example.avro.md5", - "type": "fixed", - "size": 16 - } - }, - { - "name": "recordField", - "type": { - "name": "example.avro.TestRecord", - "type": "record", - "fields": [ - { - "name": "longRecordField", - "type": "long" - }, - { - "name": "stringRecordField", - "type": "string" - }, - { - "name": "intRecordField", - "type": "int" - }, - { - "name": "floatRecordField", - "type": "float" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/test/resources/avro/output/output_person.avro b/test/resources/avro/output/output_person.avro deleted file mode 100644 index 4bd49e5..0000000 Binary files a/test/resources/avro/output/output_person.avro and /dev/null differ diff --git a/test/resources/avro/output/output_person.avsc b/test/resources/avro/output/output_person.avsc deleted file mode 100644 index b8a2027..0000000 --- a/test/resources/avro/output/output_person.avsc +++ /dev/null @@ -1 +0,0 @@ -{"name":"Person","type":"record","fields":[{"name":"ID","type":"long"},{"name":"First","type":"string"},{"name":"Last","type":"string"},{"name":"Phone","type":"string"},{"name":"Age","type":"int"}]} \ No newline at end of file diff --git a/test/resources/avro/output/output_person2.json b/test/resources/avro/output/output_person2.json deleted file mode 100644 index 5a736bf..0000000 --- a/test/resources/avro/output/output_person2.json +++ /dev/null @@ -1,2 +0,0 @@ -{"ID":1,"First":"Dante","Last":"Hicks","Phone":"(0)","Age":32} -{"ID":2,"First":"Randal","ast": "Graves","Phone":"(555) 123-5678","Age":30} diff --git a/test/resources/avro/output/person.avro b/test/resources/avro/output/person.avro index 789ffae..f1d58dd 100644 Binary files a/test/resources/avro/output/person.avro and b/test/resources/avro/output/person.avro differ diff --git a/test/resources/output/.gitkeep b/test/resources/output/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/resources/output/ouput.css b/test/resources/output/ouput.css new file mode 100644 index 0000000..86b07b6 --- /dev/null +++ b/test/resources/output/ouput.css @@ -0,0 +1 @@ +body{margin:25px;background-color:#f0f0f0;font-family:arial,sans-serif;font-size:14px}h1{font-size:35px;font-weight:400;margin-top:5px}.someclass{color:red}#someid{color:green} \ No newline at end of file diff --git a/test/resources/output/out.txt b/test/resources/output/out.txt new file mode 100644 index 0000000..4177152 --- /dev/null +++ b/test/resources/output/out.txt @@ -0,0 +1 @@ +4493b97b4a0d21fc561070c48d4a62a9bfbeb78c5d9b3c59abf6d41f70da2e9bd45af63d8c62812cf41e50e352ec41b4f407f71d5778b575c503b70081e7a151 \ No newline at end of file