@travetto/asset
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -30,3 +30,3 @@ { | ||
}, | ||
"version": "0.0.23" | ||
"version": "0.0.24" | ||
} |
@@ -6,2 +6,4 @@ travetto: Asset | ||
If `GraphicsMagick` is not installed, the framework will spin up a `docker` container to provide needed functionality. | ||
The primary driver for the Asset framework is an `AssetSource` which needs to be implemented | ||
@@ -13,2 +15,2 @@ to provide code on how to read and write files. | ||
- `asset-mongo` provides the mongodb driver for file management | ||
- `asset-s3` provides the S3 driver for file management |
import * as fs from 'fs'; | ||
import * as util from 'util'; | ||
import { CommandService } from '@travetto/exec'; | ||
import { CommandService, spawn } from '@travetto/exec'; | ||
import { Cacheable } from '@travetto/cache'; | ||
import { Injectable } from '@travetto/di'; | ||
import { CommonProcess, ExecutionResult } from '@travetto/exec/src/types'; | ||
import { AppEnv } from '@travetto/base'; | ||
@@ -11,4 +13,2 @@ import { AssetService } from './asset'; | ||
import { AssetUtil } from '../util'; | ||
import { CommonProcess, ExecutionResult } from '@travetto/exec/src/types'; | ||
import { AppEnv } from '@travetto/base'; | ||
@@ -21,10 +21,11 @@ const fsUnlinkAsync = util.promisify(fs.unlink); | ||
converter = new CommandService({ image: 'v4tech/imagemagick' }); | ||
converter = new CommandService({ | ||
image: 'v4tech/imagemagick', | ||
checkForLocal: async () => { | ||
return (await spawn('convert --version')[1]).valid; | ||
} | ||
}); | ||
constructor(private assetService: AssetService) { } | ||
async postConstruct() { | ||
await this.converter.init(); | ||
} | ||
@Cacheable({ | ||
@@ -46,3 +47,3 @@ max: 1000, | ||
const [proc, prom] = this.converter.exec('convert', '-resize', `${options.w}x${options.h}`, '-auto-orient', '-', '-'); | ||
const [proc, prom] = await this.converter.exec('convert', '-resize', `${options.w}x${options.h}`, '-auto-orient', '-', '-'); | ||
@@ -49,0 +50,0 @@ info.stream.pipe(proc.stdin); |
13560
339
15