start implementation of Smartfile class

This commit is contained in:
Philipp Kunz 2017-03-04 21:10:46 +01:00
parent 943a0c30c2
commit e9c9e95118
13 changed files with 493 additions and 379 deletions

3
dist/index.js vendored
View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global"); require("typings-global");
const SmartfileFs = require("./smartfile.fs"); const SmartfileFs = require("./smartfile.fs");
const SmartfileInterpreter = require("./smartfile.interpreter"); const SmartfileInterpreter = require("./smartfile.interpreter");
@ -11,4 +12,4 @@ exports.interpreter = SmartfileInterpreter;
exports.memory = SmartfileMemory; exports.memory = SmartfileMemory;
exports.remote = SmartfileRemote; exports.remote = SmartfileRemote;
exports.requireReload = SmartfileFs.requireReload; exports.requireReload = SmartfileFs.requireReload;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBR3ZCLDhDQUE2QztBQUM3QyxnRUFBK0Q7QUFDL0Qsc0RBQXFEO0FBQ3JELHNEQUFxRDtBQUVyRCw2RUFBdUQ7QUFBL0Msa0RBQUEsU0FBUyxDQUFBO0FBRU4sUUFBQSxFQUFFLEdBQUcsV0FBVyxDQUFBO0FBQ2hCLFFBQUEsV0FBVyxHQUFHLG9CQUFvQixDQUFBO0FBQ2xDLFFBQUEsTUFBTSxHQUFHLGVBQWUsQ0FBQTtBQUN4QixRQUFBLE1BQU0sR0FBRyxlQUFlLENBQUE7QUFDeEIsUUFBQSxhQUFhLEdBQUcsV0FBVyxDQUFDLGFBQWEsQ0FBQSJ9 //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUd2Qiw4Q0FBNkM7QUFDN0MsZ0VBQStEO0FBQy9ELHNEQUFxRDtBQUNyRCxzREFBcUQ7QUFFckQsNkVBQXVEO0FBQS9DLGtEQUFBLFNBQVMsQ0FBQTtBQUVOLFFBQUEsRUFBRSxHQUFHLFdBQVcsQ0FBQTtBQUNoQixRQUFBLFdBQVcsR0FBRyxvQkFBb0IsQ0FBQTtBQUNsQyxRQUFBLE1BQU0sR0FBRyxlQUFlLENBQUE7QUFDeEIsUUFBQSxNQUFNLEdBQUcsZUFBZSxDQUFBO0FBQ3hCLFFBQUEsYUFBYSxHQUFHLFdBQVcsQ0FBQyxhQUFhLENBQUEifQ==

View File

@ -1,3 +1,16 @@
export declare class Smartfile { /// <reference types="node" />
constructor(); export interface ISmartfileConstructorOptions {
path?: string;
contentsString?: string;
contentBuffer?: Buffer;
}
export declare class Smartfile {
path: string;
contents: Buffer;
constructor(optionsArg: ISmartfileConstructorOptions);
/**
* set contents from string
* @param contentString
*/
setContentFromString(contentString: string): void;
} }

View File

@ -1,7 +1,22 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Smartfile { class Smartfile {
constructor() { constructor(optionsArg) {
if (optionsArg.contentBuffer) {
this.contents = optionsArg.contentBuffer;
}
else if (optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString);
}
this.path = optionsArg.path;
}
/**
* set contents from string
* @param contentString
*/
setContentFromString(contentString) {
this.contents = new Buffer(contentString);
} }
} }
exports.Smartfile = Smartfile; exports.Smartfile = Smartfile;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtJQUNJO0lBRUEsQ0FBQztDQUNKO0FBSkQsOEJBSUMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBUUE7SUFHRSxZQUFZLFVBQXdDO1FBQ2xELEVBQUUsQ0FBQyxDQUFDLFVBQVUsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO1lBQzdCLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFDLGFBQWEsQ0FBQTtRQUMxQyxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQSxDQUFDLFVBQVUsQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDO1lBQ3BDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxNQUFNLENBQUMsVUFBVSxDQUFDLGNBQWMsQ0FBQyxDQUFBO1FBQ3ZELENBQUM7UUFDRCxJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUE7SUFDN0IsQ0FBQztJQUVEOzs7T0FHRztJQUNILG9CQUFvQixDQUFDLGFBQXFCO1FBQ3hDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxNQUFNLENBQUMsYUFBYSxDQUFDLENBQUE7SUFDM0MsQ0FBQztDQUNGO0FBbkJELDhCQW1CQyJ9

View File

@ -1,4 +1,5 @@
import 'typings-global'; import 'typings-global';
import { Smartfile } from './smartfile.classes.smartfile';
/** /**
* *
* @param filePath * @param filePath
@ -90,6 +91,7 @@ export declare let toObjectSync: (filePathArg: any, fileTypeArg?: any) => any;
* @returns {string|Buffer|any} * @returns {string|Buffer|any}
*/ */
export declare let toStringSync: (filePath: any) => any; export declare let toStringSync: (filePath: any) => any;
export declare let fileTreeToObject: (dirPathArg: string, miniMatchFilter: string) => Promise<Smartfile[]>;
/** /**
* *
* @param filePathArg * @param filePathArg

23
dist/smartfile.fs.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global"); require("typings-global");
const plugins = require("./smartfile.plugins"); const plugins = require("./smartfile.plugins");
exports.filetype = (pathArg) => { exports.filetype = (pathArg) => {
@ -18,4 +19,4 @@ exports.objectFile = (fileStringArg, fileTypeArg) => {
break; break;
} }
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFFdkIsK0NBQStDO0FBRXBDLFFBQUEsUUFBUSxHQUFHLENBQUMsT0FBZTtJQUNsQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtJQUMzQyxJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLFlBQVksRUFBQyxJQUFJLENBQUMsQ0FBQSxDQUFDLHlCQUF5QjtJQUMzRSxNQUFNLENBQUMsUUFBUSxDQUFBO0FBQ25CLENBQUMsQ0FBQTtBQUVVLFFBQUEsVUFBVSxHQUFHLENBQUMsYUFBcUIsRUFBRSxXQUFXO0lBQ3ZELE1BQU0sQ0FBQyxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDbEIsS0FBSyxLQUFLLENBQUU7UUFDWixLQUFLLE1BQU07WUFDUCxNQUFNLENBQUMsT0FBTyxDQ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QUFBO1FBQy9DLEtBQUssTUFBTTtZQUNQLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLGFBQWEsQ0FBQyxDQUFBO1FBQ3BDO1lBQ0ksT0FBTyxDQUFDLEtBQUssQ0FBQyxZQUFZLEdBQUcsV0FBVyxDQUFDLElBQUksR0FBRyxnQkFBZ0IsQ0FBQyxDQUFBO1lBQ2pFLEtBQUssQ0FBQTtJQUNiLENBQUM7QUFDTCxDQUFDLENBQUEifQ==

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global"); require("typings-global");
exports.fs = require("fs"); exports.fs = require("fs");
exports.fsExtra = require("fs-extra"); exports.fsExtra = require("fs-extra");
@ -10,4 +11,4 @@ exports.requireReload = require('require-reload');
exports.smartpath = require("smartpath"); exports.smartpath = require("smartpath");
exports.vinylFile = require('vinyl-file'); exports.vinylFile = require('vinyl-file');
exports.yaml = require('js-yaml'); exports.yaml = require('js-yaml');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGZpbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDJCQUFnQztBQUNoQyxzQ0FBMkM7QUFDaEMsUUFBQSxJQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBQ2pDLCtCQUFvQztBQUNwQyw4QkFBbUM7QUFDbkMsK0NBQW9EO0FBQ3pDLFFBQUEsYUFBYSxHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3BELHlDQUE4QztBQUNuQyxRQUFBLFNBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7QUFDakMsUUFBQSxJQUFJLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGZpbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQkFBZ0M7QUFDaEMsc0NBQTJDO0FBQ2hDLFFBQUEsSUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQTtBQUNqQywrQkFBb0M7QUFDcEMsOEJBQW1DO0FBQ25DLCtDQUFvRDtBQUN6QyxRQUFBLGFBQWEsR0FBRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FBQTtBQUNwRCx5Q0FBOEM7QUFDbkMsUUFBQSxTQUFTLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFBO0FBQ2pDLFFBQUEsSUFBSSxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQSJ9

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global"); require("typings-global");
const plugins = require("./smartfile.plugins"); const plugins = require("./smartfile.plugins");
/* export let toFs = function (from: string, toPath: string) { /* export let toFs = function (from: string, toPath: string) {
@ -47,4 +48,4 @@ exports.toString = (fromArg) => {
}); });
return done.promise; return done.promise;
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnJlbW90ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZmlsZS5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQ0FBK0M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sQ0FBQSJ9

File diff suppressed because one or more lines are too long

View File

@ -65,6 +65,17 @@ describe('smartfile', function () {
}) })
}) })
}) })
describe('toObjectFromFileTree', function () {
it('should read a file tree into an Object', function () {
smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt')
.then((fileArrayArg) => {
// expect(fileArrayArg[1]).to.be.instanceof(smartfile.Smartfile)
})
})
})
describe('.copy()', function () { describe('.copy()', function () {
it('should copy a directory', function () { it('should copy a directory', function () {
smartfile.fs.copy('./test/testfolder/', './test/temp/') smartfile.fs.copy('./test/testfolder/', './test/temp/')

View File

@ -1,5 +1,28 @@
export class Smartfile { import * as plugins from './smartfile.plugins'
constructor() {
export interface ISmartfileConstructorOptions {
path?: string
contentsString?: string
contentBuffer?: Buffer
}
export class Smartfile {
path: string
contents: Buffer
constructor(optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) {
this.contents = optionsArg.contentBuffer
} else if(optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString)
}
this.path = optionsArg.path
}
/**
* set contents from string
* @param contentString
*/
setContentFromString(contentString: string) {
this.contents = new Buffer(contentString)
} }
} }

View File

@ -2,6 +2,9 @@ import 'typings-global'
import plugins = require('./smartfile.plugins') import plugins = require('./smartfile.plugins')
import SmartfileInterpreter = require('./smartfile.interpreter') import SmartfileInterpreter = require('./smartfile.interpreter')
import { Smartfile } from './smartfile.classes.smartfile'
import * as memory from './smartfile.memory' import * as memory from './smartfile.memory'
/*=============================================================== /*===============================================================
============================ Checks ============================= ============================ Checks =============================
@ -206,6 +209,18 @@ export let toStringSync = function(filePath) {
return fileString return fileString
} }
export let fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string) => {
let fileTree = await listFileTree(dirPathArg, miniMatchFilter)
let smartfileArray: Smartfile[] = []
for (let filePath of fileTree) {
smartfileArray.push(new Smartfile({
path: filePath,
contentBuffer: new Buffer(toStringSync(filePath))
}))
}
return smartfileArray
}
/** /**
* *
* @param filePathArg * @param filePathArg