@travetto/asset
Advanced tools
Comparing version 0.5.8 to 0.5.9
@@ -10,6 +10,6 @@ { | ||
"dependencies": { | ||
"@travetto/cache": "^0.5.5", | ||
"@travetto/di": "^0.5.14", | ||
"@travetto/exec": "^0.5.4", | ||
"@travetto/net": "^0.5.3", | ||
"@travetto/cache": "^0.5.6", | ||
"@travetto/di": "^0.5.16", | ||
"@travetto/exec": "^0.5.5", | ||
"@travetto/net": "^0.5.4", | ||
"@types/file-type": "^10.6.0", | ||
@@ -22,3 +22,3 @@ "@types/mime": "^2.0.0", | ||
"devDependencies": { | ||
"@travetto/test": "^0.5.6" | ||
"@travetto/test": "^0.5.9" | ||
}, | ||
@@ -45,4 +45,4 @@ "homepage": "https://travetto.io", | ||
}, | ||
"version": "0.5.8", | ||
"gitHead": "c966f7a6d0670d9ee4237576e7d5443285940bfc" | ||
"version": "0.5.9", | ||
"gitHead": "c0290bd31a10415a04474ac8680c71309c0d3307" | ||
} |
@@ -1,3 +0,7 @@ | ||
import { FsUtil } from '@travetto/base'; | ||
import * as fs from 'fs'; | ||
import * as util from 'util'; | ||
const fsUnlink = util.promisify(fs.unlink); | ||
const fsReadFile = util.promisify(fs.readFile); | ||
export interface AssetFile { | ||
@@ -45,6 +49,6 @@ name: string; | ||
async read() { | ||
const res = (await FsUtil.readFileAsync(this.path)).toString(); | ||
await FsUtil.unlinkAsync(this.path); | ||
const res = (await fsReadFile(this.path)).toString(); | ||
await fsUnlink(this.path); | ||
return res; | ||
} | ||
} |
import * as fs from 'fs'; | ||
import * as util from 'util'; | ||
import { Injectable } from '@travetto/di'; | ||
import { FsUtil } from '@travetto/base'; | ||
@@ -9,2 +9,4 @@ import { Asset } from '../model'; | ||
const fsUnlink = util.promisify(fs.unlink); | ||
@Injectable() | ||
@@ -37,3 +39,3 @@ export class AssetService { | ||
try { | ||
await FsUtil.unlinkAsync(asset.path); | ||
await fsUnlink(asset.path); | ||
} catch (e) { | ||
@@ -40,0 +42,0 @@ // Do nothings |
import * as fs from 'fs'; | ||
import * as util from 'util'; | ||
@@ -6,3 +7,2 @@ import { CommandService, ExecUtil } from '@travetto/exec'; | ||
import { Injectable } from '@travetto/di'; | ||
import { FsUtil } from '@travetto/base'; | ||
@@ -14,2 +14,4 @@ import { AssetService } from './asset'; | ||
const fsUnlink = util.promisify(fs.unlink); | ||
@Injectable() | ||
@@ -30,3 +32,3 @@ export class ImageService { | ||
dispose: (key: string, n: Promise<string | undefined>) => { | ||
n.then(v => v ? FsUtil.unlinkAsync(v) : undefined).catch(err => { | ||
n.then(v => v ? fsUnlink(v) : undefined).catch(err => { | ||
console.error(err); | ||
@@ -33,0 +35,0 @@ }); |
import * as fs from 'fs'; | ||
import * as util from 'util'; | ||
import * as mime from 'mime'; | ||
import * as path from 'path'; | ||
import * as fileType from 'file-type'; | ||
@@ -13,4 +13,9 @@ import * as os from 'os'; | ||
const tmpDir = path.resolve(os.tmpdir()); | ||
const fsStat = util.promisify(fs.stat); | ||
const fsOpen = util.promisify(fs.open); | ||
const fsRead = util.promisify(fs.read); | ||
const fsRename = util.promisify(fs.rename); | ||
const tmpDir = FsUtil.toUnix(os.tmpdir()); | ||
export class AssetUtil { | ||
@@ -21,3 +26,3 @@ | ||
const name = `image-${now.getFullYear()}-${now.getMonth()}-${now.getDate()}-${process.pid}-${(Math.random() * 100000000 + 1).toString(36)}.${ext}`; | ||
return path.resolve(tmpDir, name); | ||
return FsUtil.resolveUnix(tmpDir, name); | ||
} | ||
@@ -35,3 +40,3 @@ | ||
const size = (await FsUtil.statAsync(pth)).size; | ||
const size = (await fsStat(pth)).size; | ||
@@ -87,5 +92,5 @@ const upload = this.fileToAsset({ | ||
static async readChunk(filePath: string, bytes: number) { | ||
const fd = await FsUtil.openAsync(filePath, 'r'); | ||
const fd = await fsOpen(filePath, 'r'); | ||
const buffer = new Buffer(bytes); | ||
await FsUtil.readAsync(fd, buffer, 0, bytes, 0); | ||
await fsRead(fd, buffer, 0, bytes, 0); | ||
return buffer; | ||
@@ -125,3 +130,3 @@ } | ||
} | ||
await FsUtil.renameAsync(filePath, newFilePath); | ||
await fsRename(filePath, newFilePath); | ||
filePath = newFilePath; | ||
@@ -128,0 +133,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13464
270
Updated@travetto/cache@^0.5.6
Updated@travetto/di@^0.5.16
Updated@travetto/exec@^0.5.5
Updated@travetto/net@^0.5.4