Skip to content

Commit 4f03d2c

Browse files
authored
Merge pull request #59 from codingtools/refactoring-v0.1.6
Refactoring v0.1.6
2 parents 7ca141e + e340cac commit 4f03d2c

14 files changed

+25
-90
lines changed

β€Ž.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node_modules
99
/.idea
1010
cdt.iml
1111
**/.DS_Store
12+
output/*
13+
!output/.gitkeep

β€Žsrc/commands/hash.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class Hash extends Command {
1616
type: flags.string({char: 't' , description: 'type of hash [SHA1(default), MD5, SHA256, SHA512, RMD160 or RIPEMD160]'}),
1717
string: flags.string({char: 's' , description: 'string to be hashed'}),
1818
file: flags.string({char: 'f' , description: 'file to be hashed'}),
19-
outputFile: flags.string({char: 'o' , description: 'output file path'}),
19+
output: flags.string({char: 'o' , description: 'output file path'}),
2020
}
2121

2222
static args = [{name: 'string'}]
@@ -47,8 +47,8 @@ export default class Hash extends Command {
4747
let hashed: string = hashObject(args.string)
4848
Logger.success(this, `[${flags.type.toUpperCase()}] ${hashed}`)
4949

50-
if (flags.outputFile) { // if output path is provided then write to file also
51-
Utilities.writeStringToFile(this, flags.outputFile, hashed)
50+
if (flags.output) { // if output path is provided then write to file also
51+
Utilities.writeStringToFile(this, flags.output, hashed)
5252
}
5353
}
5454

β€Žsrc/commands/minify.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Minify extends Command {
1212
help: flags.help({char: 'h'}),
1313
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'}),
1414
file: flags.string({char: 'f' , description: 'file to be minified'}),
15-
outputFile: flags.string({char: 'o' , description: 'output file path'}),
15+
output: flags.string({char: 'o' , description: 'output file path'}),
1616
}
1717

1818
static args = [{name: 'file'}]
@@ -100,8 +100,8 @@ export default class Minify extends Command {
100100
Logger.progressStop(this, `file: ${flags.file} minified`)
101101
// }, 1000)
102102

103-
if (flags.outputFile) { // if output path is provided then write to file also
104-
Utilities.writeStringToFile(this, flags.outputFile, output)
103+
if (flags.output) { // if output path is provided then write to file also
104+
Utilities.writeStringToFile(this, flags.output, output)
105105
} else
106106
Logger.success(this, `minified output: \n${output}`)
107107
}

β€Žtest/commands/hash.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {expect, test} from '@oclif/test'
22

33
describe('hash', () => {
44
test
5-
.timeout(10000) // added timeout to resolve timeout problem
5+
.timeout(20000) // added timeout to resolve timeout problem
66
.stdout()
77
.command(['hash', 'ashish'])
88
.it("Check default type -> cdt hash 'ashish'", ctx => {
@@ -107,6 +107,13 @@ describe('hash', () => {
107107
expect(ctx.stdout).to.contain('4493b97b4a0d21fc561070c48d4a62a9bfbeb78c5d9b3c59abf6d41f70da2e9bd45af63d8c62812cf41e50e352ec41b4f407f71d5778b575c503b70081e7a151')
108108
})
109109

110+
test
111+
.stdout()
112+
.command(['hash', '-f', 'test/resources/test.txt', '-t', 'sha512', '--output', 'test/resources/output/out.txt'])
113+
.it("File Hashing, output to a file", ctx => {
114+
expect(ctx.stdout).to.contain('βœ” success output written to file')
115+
})
116+
110117
//file input - file not found
111118
test
112119
.stdout()

β€Žtest/commands/minify.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {expect, test} from '@oclif/test'
22

33
describe('minify', () => {
44
test
5+
.timeout(20000) // added timeout to resolve timeout problem
56
.stdout()
67
.command(['minify', '-t', 'js'])
78
.exit(0)
@@ -46,4 +47,10 @@ describe('minify', () => {
4647
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}')
4748
})
4849

50+
test
51+
.stdout()
52+
.command(['minify', '-f', 'test/resources/test.css', '--output', 'test/resources/output/ouput.css'])
53+
.it('Minify CSS, output to a file', ctx => {
54+
expect(ctx.stdout).to.contain('βœ” success output written to file')
55+
})
4956
})

β€Žtest/resources/avro/output/.gitkeep

Whitespace-only changes.

β€Žtest/resources/avro/output/output_complex.avsc

Lines changed: 0 additions & 80 deletions
This file was deleted.
-286 Bytes
Binary file not shown.

β€Žtest/resources/avro/output/output_person.avsc

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žtest/resources/avro/output/output_person2.json

Lines changed: 0 additions & 2 deletions
This file was deleted.
0 Bytes
Binary file not shown.

β€Žtest/resources/output/.gitkeep

Whitespace-only changes.

β€Žtest/resources/output/ouput.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/resources/output/out.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4493b97b4a0d21fc561070c48d4a62a9bfbeb78c5d9b3c59abf6d41f70da2e9bd45af63d8c62812cf41e50e352ec41b4f407f71d5778b575c503b70081e7a151

0 commit comments

Comments
Β (0)