fix Smartfile class

This commit is contained in:
Philipp Kunz 2017-04-29 17:20:09 +02:00
parent 7457093476
commit 32cdac5b38
3 changed files with 25 additions and 9 deletions

View File

@ -1,7 +1,7 @@
/// <reference types="node" />
export interface ISmartfileConstructorOptions {
path?: string;
contentsString?: string;
contentString?: string;
contentBuffer?: Buffer;
}
/**
@ -14,9 +14,13 @@ export declare class Smartfile {
*/
path: string;
/**
* The contents of the file as Buffer
* gulp-compatibility: alias of this.contentBuffer
*/
contents: Buffer;
/**
* the content of the file as Buffer
*/
contentBuffer: Buffer;
/**
* The current working directory of the file
*/

View File

@ -19,10 +19,14 @@ class Smartfile {
*/
constructor(optionsArg) {
if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer;
this.contents = optionsArg.contentBuffer;
}
else if (optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString);
else if (optionsArg.contentString) {
this.contents = Buffer.from(optionsArg.contentString);
}
else {
console.log('created empty Smartfile?');
}
this.path = optionsArg.path;
}
@ -56,4 +60,4 @@ class Smartfile {
}
}
exports.Smartfile = Smartfile;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFRQTs7O0dBR0c7QUFDSDtJQXFCRTs7O09BR0c7SUFDSCxZQUFhLFVBQXdDO1FBQ25ELEVBQUUsQ0FBQyxDQUFDLFVBQVUsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO1lBQzdCLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFDLGFBQWEsQ0FBQTtRQUMxQyxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQU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E7UUFDMUMsQ0FBQztRQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQztZQUNwQyxJQUFJLENBQUMsUUFBUSxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLGFBQWEsQ0FBQyxDQUFBO1FBQ3ZELENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE9BQU8sQ0FBQyxHQUFHLENBQUMsMEJBQTBCLENBQUMsQ0FBQTtRQUN6QyxDQUFDO1FBQ0QsSUFBSSxDQUFDLElBQUksR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFBO0lBQzdCLENBQUM7SUFFRDs7O09BR0c7SUFDSCxJQUFJLFFBQVE7UUFDVixNQUFNLENBQUMsRUFBRSxDQUFBO0lBQ1gsQ0FBQztJQUdEOzs7T0FHRztJQUNILHFCQUFxQixDQUFDLGFBQXFCO1FBQ3pDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxNQUFNLENBQUMsYUFBYSxDQUFDLENBQUE7SUFDM0MsQ0FBQztJQUVEOztPQUVHO0lBQ0csS0FBSzs7UUFFWCxDQUFDO0tBQUE7SUFFRDs7T0FFRztJQUNHLElBQUk7O1FBQ1YsQ0FBQztLQUFBO0NBQ0Y7QUF2RUQsOEJBdUVDIn0=

View File

@ -2,7 +2,7 @@ import * as plugins from './smartfile.plugins'
export interface ISmartfileConstructorOptions {
path?: string
contentsString?: string
contentString?: string
contentBuffer?: Buffer
}
@ -17,10 +17,15 @@ export class Smartfile {
path: string
/**
* The contents of the file as Buffer
* gulp-compatibility: alias of this.contentBuffer
*/
contents: Buffer
/**
* the content of the file as Buffer
*/
contentBuffer: Buffer
/**
* The current working directory of the file
*/
@ -37,9 +42,12 @@ export class Smartfile {
*/
constructor (optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer
this.contents = optionsArg.contentBuffer
} else if (optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString)
} else if (optionsArg.contentString) {
this.contents = Buffer.from(optionsArg.contentString)
} else {
console.log('created empty Smartfile?')
}
this.path = optionsArg.path
}