Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cancerberoSgx committed Nov 11, 2018
1 parent 07c5bde commit 0f38bfd
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 43 deletions.
4 changes: 2 additions & 2 deletions spec/callSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { blobToString, buildInputFile, Call, extractInfo } from '../src'

describe('call', () => {
export default describe('call', () => {

it('should print image metadata as json if output file is .json', async done => {
const processedFiles = await Call([await buildInputFile('fn.png', 'srcFile.png')], ['convert', 'srcFile.png', 'info.json'])
Expand All @@ -16,7 +16,7 @@ describe('call', () => {
expect(info[0].image.geometry.height).toBe(145)
const processedFiles = await Call(
[img],
['convert', 'fn.png', '-rotate', '90', '-resize', '200%', 'output.png']
['convert', 'fn.png', '-rotate', '90', '-resize', '200%', 'output.png'],
)
expect(processedFiles[0].name).toBe('output.png')
info = await extractInfo(processedFiles[0])
Expand Down
16 changes: 8 additions & 8 deletions spec/executeSpec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildInputFile, compare, extractInfo } from '../src'
import { execute, executeOne } from '../src'

describe('execute', () => {
export default describe('execute', () => {

describe('executeOne', () => {
it('should run convert -resize', async done => {
Expand All @@ -13,7 +13,7 @@ describe('execute', () => {

const { outputFiles } = await executeOne({
inputFiles: [img1],
commands: [['convert', 'holocaust.jpg', '-resize', '123x321!', 'resized.png']]
commands: [['convert', 'holocaust.jpg', '-resize', '123x321!', 'resized.png']],
})
info = await extractInfo(outputFiles[0])
expect(info[0].image.formatDescription.toLowerCase()).toBe('png')
Expand Down Expand Up @@ -41,12 +41,12 @@ describe('execute', () => {
commands: [
['convert', 'image1.png', '-rotate', '70', 'image2.gif'],
// heads up: next command uses 'image2.gif' which was the output of previous command:
['convert', 'image2.gif', '-scale', '23%', 'image3.jpg']
]
['convert', 'image2.gif', '-scale', '23%', 'image3.jpg'],
],
})
const result2 = await executeOne({
inputFiles: [await buildInputFile('fn.png', 'image1.png')],
commands: [['convert', 'image1.png', '-rotate', '70', '-scale', '23%', 'image2.gif']]
commands: [['convert', 'image1.png', '-rotate', '70', '-scale', '23%', 'image2.gif']],
})
expect(await compare(result.outputFiles.find(f => f.name === 'image3.jpg'), result2.outputFiles[0])).toBe(true)
done()
Expand All @@ -58,12 +58,12 @@ describe('execute', () => {
commands: [
'convert image1.png -rotate 70 image2.gif',
// heads up: next command uses 'image2.gif' which was the output of previous command:
'convert image2.gif -scale 23% image3.jpg'
]
'convert image2.gif -scale 23% image3.jpg',
],
})
const result2 = await executeOne({
inputFiles: [await buildInputFile('fn.png', 'image1.png')],
commands: ['convert image1.png -rotate 70 -scale 23% image2.gif']
commands: ['convert image1.png -rotate 70 -scale 23% image2.gif'],
})
expect(await compare(result.outputFiles.find(f => f.name === 'image3.jpg'), result2.outputFiles[0])).toBe(true)
done()
Expand Down
2 changes: 1 addition & 1 deletion spec/formatSpec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pmap from 'p-map'
import { buildInputFile, compare } from '../src'

describe('formats', () => {
export default describe('formats', () => {

const formats = ['jpg', 'png', 'psd', 'tiff', 'xcf', 'gif', 'bmp']

Expand Down
2 changes: 1 addition & 1 deletion spec/imageHomeSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildInputFile, createImageHome } from '../src'

describe('imageHome', () => {
export default describe('imageHome', () => {
it('should allow me to register an image', async done => {
const imageHome = createImageHome()
expect(imageHome.isRegistered('fn.png')).toBeFalsy()
Expand Down
18 changes: 9 additions & 9 deletions spec/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000

import * as callSpec from './callSpec'
import * as executeSpec from './executeSpec'
import * as formatSpec from './formatSpec'
import * as imageHomeSpec from './imageHomeSpec'
import * as testAssetsSpec from './testAssetsSpec'
import * as cliSpec from './util/cliSpec'
import * as htmlSpec from './util/htmlSpec'
import * as fileSpec from './util/fileSpec'
import * as imageSpec from './util/imageSpec'
export * from './callSpec'
export * from './executeSpec'
export * from './formatSpec'
export * from './imageHomeSpec'
export * from './testAssetsSpec'
export * from './util/cliSpec'
export * from './util/htmlSpec'
export * from './util/fileSpec'
export * from './util/imageSpec'
4 changes: 1 addition & 3 deletions spec/testAssetsSpec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('assets', () => {
export default describe('assets', () => {
it('rotate.png and magick.wasm resources should be available in orther these tests to run', async done => {
let r = await fetch('magick.wasm')
expect(r.ok).toBe(true)
Expand All @@ -12,5 +12,3 @@ describe('assets', () => {
done()
})
})

export default ''
2 changes: 1 addition & 1 deletion spec/util/cliSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { arrayToCli, cliToArray } from '../../src'

describe('util/cli', () => {
export default describe('util/cli', () => {

describe('arrayToCli', () => {
it('should support simple commands', () => {
Expand Down
6 changes: 3 additions & 3 deletions spec/util/fileSpec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { blobToString, buildInputFile, Call, compare, extractInfo, getFileNameExtension, inputFileToOutputFile, outputFileToInputFile, getFileName } from '../../src'

describe('util/file', () => {
export default describe('util/file', () => {

describe('buildInputFile', () => {
async function test(urlToFnPng) {
const file = await buildInputFile(urlToFnPng)
const processedFiles = await Call(
[file],
['convert', 'fn.png', 'info.json']
['convert', 'fn.png', 'info.json'],
)
expect(processedFiles[0].name).toBe('info.json')
let info = JSON.parse(await blobToString(processedFiles[0].blob))
Expand All @@ -33,7 +33,7 @@ describe('util/file', () => {
done()
})

xit('should support data:// urls with embedded image content', () => {})
xit('should support data:// urls with embedded image content', () => { })
})

describe('outputFileToInputFile and inputFileToOutputFile', () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/util/htmlSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildInputFile, loadImageElement, compare, execute } from '../../src'

describe('util/html', () => {
export default describe('util/html', () => {

describe('loadImageElement', () => {

Expand Down
2 changes: 1 addition & 1 deletion spec/util/imageSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildInputFile, compare, extractInfo, MagickInputFile, getFileNameExtension, Call, outputFileToInputFile } from '../../src'

describe('util/image', () => {
export default describe('util/image', () => {

describe('compareImage', () => {

Expand Down
4 changes: 2 additions & 2 deletions src/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function execute(config: ExecuteConfig): Promise<ExecuteResult> {
async function mapper(c: Command) {
const thisConfig = {
inputFiles: Object.keys(allInputFiles).map(name => allInputFiles[name]),
commands: [c]
commands: [c],
}
const result = await executeOne(thisConfig)
await pMap(result.outputFiles, async f => {
Expand All @@ -88,6 +88,6 @@ export async function execute(config: ExecuteConfig): Promise<ExecuteResult> {
const commands = asCommand(config.commands)
await pMap(commands, mapper, { concurrency: 1 })
return {
outputFiles: Object.keys(allOutputFiles).map(name => allOutputFiles[name])
outputFiles: Object.keys(allOutputFiles).map(name => allOutputFiles[name]),
}
}
8 changes: 4 additions & 4 deletions src/magickApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function Call(inputFiles: MagickInputFile[], command: string[]): Promise<
const request = {
files: inputFiles,
args: command,
requestNumber: magickWorkerPromisesKey
requestNumber: magickWorkerPromisesKey,
}

const emptyPromise = CreatePromiseEvent()
Expand All @@ -35,9 +35,9 @@ function CreatePromiseEvent() {
const emptyPromise = new Promise((resolve, reject) => {
resolver = resolve
rejecter = reject
})
emptyPromise['resolve'] = resolver
emptyPromise['reject'] = rejecter
}) as Promise<{}> & {resolve?: any, reject?: any}
emptyPromise.resolve = resolver
emptyPromise.reject = rejecter
return emptyPromise
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export function uint8ArrayToBlob(arr: Uint8Array): Blob {
export async function outputFileToInputFile(file: MagickOutputFile, name: string = file.name): Promise<MagickInputFile> {
return {
name,
content: await blobToUint8Array(file.blob)
content: await blobToUint8Array(file.blob),
}
}

export function inputFileToOutputFile(file: MagickInputFile, name: string = file.name): MagickOutputFile {
return {
name,
blob: uint8ArrayToBlob(file.content)
blob: uint8ArrayToBlob(file.content),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function compare(img1: MagickFile, img2: MagickFile, error: number
'-resize', '256x256^!',
'-metric', 'RMSE',
'-format', '%[distortion]',
'-compare', 'info:info.txt']
'-compare', 'info:info.txt'],
)
const n = await blobToString(result[0].blob)
const identical = parseFloat(n)
Expand Down
5 changes: 1 addition & 4 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
"max-line-length": [ true, 185 ],
"member-access": false,
"member-ordering": [ false ],
"no-bitwise": false,
"no-empty": false,
"no-string-literal": false,
"ordered-imports": false,
"arrow-parens": [ true, "ban-single-arg-parens" ],
"unified-signatures": false,
"array-type": [ true, "array" ],
"ban-types": false,
"max-classes-per-file": false,
"no-unused-expression": false,
"quotemark": [true, "single"],
"semicolon": [true, "never"],
"indent": [true, "spaces", 2],
Expand All @@ -32,7 +29,7 @@
true,
{
"singleline": "never",
"multiline": "never"
"multiline": "always"
}
],
"variable-name": false,
Expand Down

0 comments on commit 0f38bfd

Please sign in to comment.