diff --git a/spec/callSpec.ts b/spec/callSpec.ts index 3636251..b9eaf31 100644 --- a/spec/callSpec.ts +++ b/spec/callSpec.ts @@ -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']) @@ -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]) diff --git a/spec/executeSpec.ts b/spec/executeSpec.ts index e5aa9d1..df892c5 100644 --- a/spec/executeSpec.ts +++ b/spec/executeSpec.ts @@ -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 => { @@ -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') @@ -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() @@ -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() diff --git a/spec/formatSpec.ts b/spec/formatSpec.ts index ae6cc49..70afa70 100644 --- a/spec/formatSpec.ts +++ b/spec/formatSpec.ts @@ -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'] diff --git a/spec/imageHomeSpec.ts b/spec/imageHomeSpec.ts index 957849f..aa395ad 100644 --- a/spec/imageHomeSpec.ts +++ b/spec/imageHomeSpec.ts @@ -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() diff --git a/spec/index.ts b/spec/index.ts index e2f4bc1..20747e5 100644 --- a/spec/index.ts +++ b/spec/index.ts @@ -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' diff --git a/spec/testAssetsSpec.ts b/spec/testAssetsSpec.ts index 52e1efd..028d394 100644 --- a/spec/testAssetsSpec.ts +++ b/spec/testAssetsSpec.ts @@ -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) @@ -12,5 +12,3 @@ describe('assets', () => { done() }) }) - -export default '' diff --git a/spec/util/cliSpec.ts b/spec/util/cliSpec.ts index c2d52c4..78235ea 100644 --- a/spec/util/cliSpec.ts +++ b/spec/util/cliSpec.ts @@ -1,6 +1,6 @@ import { arrayToCli, cliToArray } from '../../src' -describe('util/cli', () => { +export default describe('util/cli', () => { describe('arrayToCli', () => { it('should support simple commands', () => { diff --git a/spec/util/fileSpec.ts b/spec/util/fileSpec.ts index a2d4ff8..098702a 100644 --- a/spec/util/fileSpec.ts +++ b/spec/util/fileSpec.ts @@ -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)) @@ -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', () => { diff --git a/spec/util/htmlSpec.ts b/spec/util/htmlSpec.ts index ca5424a..df5a234 100644 --- a/spec/util/htmlSpec.ts +++ b/spec/util/htmlSpec.ts @@ -1,6 +1,6 @@ import { buildInputFile, loadImageElement, compare, execute } from '../../src' -describe('util/html', () => { +export default describe('util/html', () => { describe('loadImageElement', () => { diff --git a/spec/util/imageSpec.ts b/spec/util/imageSpec.ts index 259a772..516107e 100644 --- a/spec/util/imageSpec.ts +++ b/spec/util/imageSpec.ts @@ -1,6 +1,6 @@ import { buildInputFile, compare, extractInfo, MagickInputFile, getFileNameExtension, Call, outputFileToInputFile } from '../../src' -describe('util/image', () => { +export default describe('util/image', () => { describe('compareImage', () => { diff --git a/src/execute.ts b/src/execute.ts index 0813891..c8ab8d0 100644 --- a/src/execute.ts +++ b/src/execute.ts @@ -76,7 +76,7 @@ export async function execute(config: ExecuteConfig): Promise { 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 => { @@ -88,6 +88,6 @@ export async function execute(config: ExecuteConfig): Promise { 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]), } } diff --git a/src/magickApi.ts b/src/magickApi.ts index 9d15ca0..85375b0 100644 --- a/src/magickApi.ts +++ b/src/magickApi.ts @@ -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() @@ -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 } diff --git a/src/util/file.ts b/src/util/file.ts index 8db1ad0..29c98fe 100644 --- a/src/util/file.ts +++ b/src/util/file.ts @@ -36,14 +36,14 @@ export function uint8ArrayToBlob(arr: Uint8Array): Blob { export async function outputFileToInputFile(file: MagickOutputFile, name: string = file.name): Promise { 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), } } diff --git a/src/util/image.ts b/src/util/image.ts index 0afb80f..de3f08d 100644 --- a/src/util/image.ts +++ b/src/util/image.ts @@ -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) diff --git a/tslint.json b/tslint.json index bdc82d1..3a050cd 100644 --- a/tslint.json +++ b/tslint.json @@ -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], @@ -32,7 +29,7 @@ true, { "singleline": "never", - "multiline": "never" + "multiline": "always" } ], "variable-name": false,