Skip to content

Refactoring v0.1.6 #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ node_modules
/.idea
cdt.iml
**/.DS_Store
output/*
!output/.gitkeep
6 changes: 3 additions & 3 deletions src/commands/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}]
Expand Down Expand Up @@ -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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/minify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}]
Expand Down Expand Up @@ -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}`)
}
Expand Down
9 changes: 8 additions & 1 deletion test/commands/hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions test/commands/minify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
})
})
Empty file.
80 changes: 0 additions & 80 deletions test/resources/avro/output/output_complex.avsc

This file was deleted.

Binary file removed test/resources/avro/output/output_person.avro
Binary file not shown.
1 change: 0 additions & 1 deletion test/resources/avro/output/output_person.avsc

This file was deleted.

2 changes: 0 additions & 2 deletions test/resources/avro/output/output_person2.json

This file was deleted.

Binary file modified test/resources/avro/output/person.avro
Binary file not shown.
Empty file added test/resources/output/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions test/resources/output/ouput.css

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

1 change: 1 addition & 0 deletions test/resources/output/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4493b97b4a0d21fc561070c48d4a62a9bfbeb78c5d9b3c59abf6d41f70da2e9bd45af63d8c62812cf41e50e352ec41b4f407f71d5778b575c503b70081e7a151