Compare commits

..

12 Commits

Author SHA1 Message Date
b53240a2ea 4.1.9 2017-03-15 20:45:59 +01:00
2ba39cf2ac Merge branch 'master' into 'master'
fix smartfile.fs.fileTreeToObject

See merge request !1
2017-03-15 19:44:42 +00:00
675934d049 fix smartfile.fs.fileTreeToObject 2017-03-15 15:25:41 +01:00
dda4c1af07 update npmextra.json 2017-03-12 00:10:01 +01:00
214bae9931 4.1.8 2017-03-12 00:06:59 +01:00
fde809eb02 update typings, deps and ci 2017-03-12 00:06:56 +01:00
9f3a71f0b9 4.1.7 2017-03-04 21:10:50 +01:00
e9c9e95118 start implementation of Smartfile class 2017-03-04 21:10:46 +01:00
943a0c30c2 update README 2017-02-23 01:03:21 +01:00
2dad3707ee updated coverage regex 2017-02-23 00:59:45 +01:00
cd35d110a9 new .gitlab-ci.yml 2017-02-23 00:45:15 +01:00
257939462b fix README footer image 2017-02-18 17:02:40 +01:00
18 changed files with 542 additions and 403 deletions

View File

@ -1,4 +1,10 @@
image: hosttoday/ht-docker-node:npmts # gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
stages: stages:
- test - test
@ -10,6 +16,7 @@ testLEGACY:
stage: test stage: test
script: script:
- npmci test legacy - npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
allow_failure: true allow_failure: true
@ -18,6 +25,7 @@ testLTS:
stage: test stage: test
script: script:
- npmci test lts - npmci test lts
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
@ -25,6 +33,7 @@ testSTABLE:
stage: test stage: test
script: script:
- npmci test stable - npmci test stable
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker

View File

@ -33,6 +33,6 @@ smartfile | (class) a virtual representation of a file, alternative to vinyl fil
For further information read the linked docs at the top of this README. For further information read the linked docs at the top of this README.
> MIT licensed | **©** 2016 - 2017 [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
[![npm](https://pushrocks.gitlab.io/assets/repo-header.svg)](https://push.rocks) [![npm](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

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
@ -89,7 +90,8 @@ export declare let toObjectSync: (filePathArg: any, fileTypeArg?: any) => any;
* @param filePath * @param filePath
* @returns {string|Buffer|any} * @returns {string|Buffer|any}
*/ */
export declare let toStringSync: (filePath: any) => any; export declare let toStringSync: (filePath: string) => string;
export declare let fileTreeToObject: (dirPathArg: string, miniMatchFilter: string) => Promise<Smartfile[]>;
/** /**
* *
* @param filePathArg * @param filePathArg

26
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFFdkIsK0NBQStDO0FBRXBDLFFBQUEsUUFBUSxHQUFHLENBQUMsT0FBZTtJQUNsQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtJQUMzQyxJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLFlBQVksRUFBQyxJQUFJLENBQUMsQ0FBQSxDQUFDLHlCQUF5QjtJQUMzRSxNQUFNLENBQUMsUUFBUSxDQUFBO0FBQ25CLENBQUMsQ0FBQTtBQUVVLFFBQUEsVUFBVSxHQUFHLENBQUMsYUFBcUIsRUFBRSxXQUFXO0lBQ3ZELE1BQU0sQ0FBQyxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDbEIsS0FBSyxLQUFLLENBQUU7UUFDWixLQUFLLE1BQU07WUFDUCxN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UFDLGFBQWEsQ0FBQyxDQUFBO1FBQy9DLEtBQUssTUFBTTtZQUNQLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLGFBQWEsQ0FBQyxDQUFBO1FBQ3BDO1lBQ0ksT0FBTyxDQUFDLEtBQUssQ0FBQyxZQUFZLEdBQUcsV0FBVyxDQUFDLElBQUksR0FBRyxnQkFBZ0IsQ0FBQyxDQUFBO1lBQ2pFLEtBQUssQ0FBQTtJQUNiLENBQUM7QUFDTCxDQUFDLENBQUEifQ==

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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnJlbW90ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZmlsZS5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1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DQUFBO0FBQ3JCLENBQUMsQ0FBQSJ9

View File

@ -5,5 +5,10 @@
}, },
"npmdocker":{ "npmdocker":{
},
"npmci": {
"globalNpmTools": [
"npmts"
]
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "smartfile", "name": "smartfile",
"version": "4.1.6", "version": "4.1.9",
"description": "offers smart ways to work with files in nodejs", "description": "offers smart ways to work with files in nodejs",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -30,10 +30,10 @@
"@types/vinyl": "^2.0.0", "@types/vinyl": "^2.0.0",
"fs-extra": "^2.0.0", "fs-extra": "^2.0.0",
"glob": "^7.1.1", "glob": "^7.1.1",
"js-yaml": "^3.7.0", "js-yaml": "^3.8.2",
"require-reload": "0.2.2", "require-reload": "0.2.2",
"smartpath": "^3.2.7", "smartpath": "^3.2.8",
"smartq": "^1.0.4", "smartq": "^1.1.1",
"smartrequest": "^1.0.4", "smartrequest": "^1.0.4",
"typings-global": "^1.0.14", "typings-global": "^1.0.14",
"vinyl": "^2.0.1", "vinyl": "^2.0.1",
@ -41,8 +41,7 @@
}, },
"devDependencies": { "devDependencies": {
"gulp-function": "^2.2.3", "gulp-function": "^2.2.3",
"npmts-g": "^6.0.0", "smartchai": "^1.0.3",
"smartchai": "^1.0.1",
"typings-test": "^1.0.3" "typings-test": "^1.0.3"
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -7,221 +7,232 @@ import { expect } from 'smartchai'
import * as vinyl from 'vinyl' import * as vinyl from 'vinyl'
describe('smartfile', function () { describe('smartfile', function () {
describe('.fs', function () { describe('.fs', function () {
describe('.fileExistsSync', function () { describe('.fileExistsSync', function () {
it('should return an accurate boolean', function () { it('should return an accurate boolean', function () {
expect(smartfile.fs.fileExistsSync('./test/mytest.json')).to.be.true expect(smartfile.fs.fileExistsSync('./test/mytest.json')).to.be.true
expect(smartfile.fs.fileExistsSync('./test/notthere.json')).be.false expect(smartfile.fs.fileExistsSync('./test/notthere.json')).be.false
}) })
}) })
describe('.fileExists', function () { describe('.fileExists', function () {
it('should return a working promise', function () { it('should return a working promise', function () {
expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.a('promise') expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.a('promise')
expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.fulfilled expect(smartfile.fs.fileExists('./test/mytest.json')).to.be.fulfilled
expect(smartfile.fs.fileExists('./test/notthere.json')).to.not.be.fulfilled expect(smartfile.fs.fileExists('./test/notthere.json')).to.not.be.fulfilled
}) })
}) })
describe('.listFoldersSync()', function () { describe('.listFoldersSync()', function () {
it('should get the file type from a string', function () { it('should get the file type from a string', function () {
expect(smartfile.fs.listFoldersSync('./test/')).to.deep.include('testfolder') expect(smartfile.fs.listFoldersSync('./test/')).to.deep.include('testfolder')
expect(smartfile.fs.listFoldersSync('./test/')).to.not.deep.include('notExistentFolder') expect(smartfile.fs.listFoldersSync('./test/')).to.not.deep.include('notExistentFolder')
}) })
}) })
describe('.listFolders()', function () { describe('.listFolders()', function () {
it('should get the file type from a string', function (done) { it('should get the file type from a string', function (done) {
smartfile.fs.listFolders('./test/') smartfile.fs.listFolders('./test/')
.then(function (folderArrayArg) { .then(function (folderArrayArg) {
expect(folderArrayArg).to.deep.include('testfolder') expect(folderArrayArg).to.deep.include('testfolder')
expect(folderArrayArg).to.not.deep.include('notExistentFolder') expect(folderArrayArg).to.not.deep.include('notExistentFolder')
done() done()
}) })
}) })
}) })
describe('.listFilesSync()', function () { describe('.listFilesSync()', function () {
it('should get the file type from a string', function () { it('should get the file type from a string', function () {
expect(smartfile.fs.listFilesSync('./test/')).to.deep.include('mytest.json') expect(smartfile.fs.listFilesSync('./test/')).to.deep.include('mytest.json')
expect(smartfile.fs.listFilesSync('./test/')).to.not.deep.include('notExistentFile') expect(smartfile.fs.listFilesSync('./test/')).to.not.deep.include('notExistentFile')
expect(smartfile.fs.listFilesSync('./test/', /mytest\.json/)).to.deep.include('mytest.json') expect(smartfile.fs.listFilesSync('./test/', /mytest\.json/)).to.deep.include('mytest.json')
expect(smartfile.fs.listFilesSync('./test/', /mytests.json/)).to.not.deep.include('mytest.json') expect(smartfile.fs.listFilesSync('./test/', /mytests.json/)).to.not.deep.include('mytest.json')
}) })
}) })
describe('.listFiles()', function () { describe('.listFiles()', function () {
it('should get the file type from a string', function (done) { it('should get the file type from a string', function (done) {
smartfile.fs.listFiles('./test/') smartfile.fs.listFiles('./test/')
.then(function (folderArrayArg) { .then(function (folderArrayArg) {
expect(folderArrayArg).to.deep.include('mytest.json') expect(folderArrayArg).to.deep.include('mytest.json')
expect(folderArrayArg).to.not.deep.include('notExistentFile') expect(folderArrayArg).to.not.deep.include('notExistentFile')
done() done()
}) })
}) })
}) })
describe('.listFileTree()', function () { describe('.listFileTree()', function () {
it('should get a file tree', function (done) { it('should get a file tree', function (done) {
smartfile.fs.listFileTree(path.resolve('./test/'), '**/*.txt') smartfile.fs.listFileTree(path.resolve('./test/'), '**/*.txt')
.then(function (folderArrayArg) { .then(function (folderArrayArg) {
expect(folderArrayArg).to.deep.include('testfolder/testfile1.txt') expect(folderArrayArg).to.deep.include('testfolder/testfile1.txt')
expect(folderArrayArg).to.not.deep.include('mytest.json') expect(folderArrayArg).to.not.deep.include('mytest.json')
done() done()
}) })
}) })
})
describe('.copy()', function () {
it('should copy a directory', function () {
smartfile.fs.copy('./test/testfolder/', './test/temp/')
})
it('should copy a file', function () {
smartfile.fs.copy('./test/mytest.yaml', './test/temp/')
})
it('should copy a file and rename it', function () {
smartfile.fs.copy('./test/mytest.yaml', './test/temp/mytestRenamed.yaml')
})
})
describe('.remove()', function () {
it('should remove an entire directory', function () {
})
it('smartfile.fs.remove -> should remove single files', function (done) {
smartfile.fs.remove('./test/temp/mytestRenamed.yaml')
.then(() => { done() })
})
it('smartfile.fs.removeSync -> should remove single files synchronouly',function() {
smartfile.fs.removeSync('./test/temp/testfile1.txt')
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
})
it('smartfile.fs.removeMany -> should remove and array of files',function(done) {
smartfile.fs.removeMany(['./test/temp/testfile1.txt','./test/temp/testfile2.txt']).then(() => {
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false
done()
})
})
it('smartfile.fs.removeManySync -> should remove and array of single files synchronouly',function() {
smartfile.fs.removeManySync(['./test/temp/testfile1.txt','./test/temp/testfile2.txt'])
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false
})
})
}) })
describe('.interpreter', function () {
describe('.filetype()', function () { describe('toObjectFromFileTree', function () {
it('should get the file type from a string', function () { it('should read a file tree into an Object', function () {
expect(smartfile.interpreter.filetype('./somefolder/data.json')).equal('json') smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt')
}) .then((fileArrayArg) => {
}) // expect(fileArrayArg[1]).to.be.instanceof(smartfile.Smartfile)
})
})
}) })
describe('.fs', function () { describe('.copy()', function () {
describe('.toObjectSync()', function () { it('should copy a directory', function () {
it('should read an ' + '.yaml' + ' file to an object', function () { smartfile.fs.copy('./test/testfolder/', './test/temp/')
let testData = smartfile.fs.toObjectSync('./test/mytest.yaml') })
expect(testData).have.property('key1', 'this works') it('should copy a file', function () {
expect(testData).have.property('key2', 'this works too') smartfile.fs.copy('./test/mytest.yaml', './test/temp/')
})
}) it('should copy a file and rename it', function () {
it('should state unknown file type for unknown file types', function () { smartfile.fs.copy('./test/mytest.yaml', './test/temp/mytestRenamed.yaml')
let testData = smartfile.fs.toObjectSync('./test/mytest.txt') })
})
it('should read an ' + '.json' + ' file to an object', function () {
let testData = smartfile.fs.toObjectSync('./test/mytest.json')
expect(testData).have.property('key1', 'this works')
expect(testData).have.property('key2', 'this works too')
})
})
describe('.toStringSync()', function () {
it('should read a file to a string', function () {
expect(smartfile.fs.toStringSync('./test/mytest.txt'))
.to.equal('Some TestString &&%$')
})
})
describe('.toVinylSync', function () {
it('should read an ' + '.json OR .yaml' + ' file to an ' + 'vinyl file object', function () {
let testData = smartfile.fs.toVinylSync('./test/mytest.json')
expect(vinyl.isVinyl(testData)).to.be.true
})
})
}) })
describe('.remove()', function () {
it('should remove an entire directory', function () {
describe('.memory', function () { })
describe('.toGulpStream()', function () { it('smartfile.fs.remove -> should remove single files', function (done) {
it('should produce a valid gulp stream', function () { smartfile.fs.remove('./test/temp/mytestRenamed.yaml')
let localArray = ['test1', 'test2', 'test3'] .then(() => { done() })
smartfile.memory.toGulpStream(localArray) })
}) it('smartfile.fs.removeSync -> should remove single files synchronouly', function () {
}) smartfile.fs.removeSync('./test/temp/testfile1.txt')
describe('toVinylFileSync()', function () { expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
it('should produce a vinylFile', function () { })
let localString = 'myString' it('smartfile.fs.removeMany -> should remove and array of files', function (done) {
let localOptions = { filename: 'vinylfile2', base: '/someDir' } smartfile.fs.removeMany([ './test/temp/testfile1.txt', './test/temp/testfile2.txt' ]).then(() => {
expect(smartfile.memory.toVinylFileSync(localString, localOptions) instanceof vinyl).to.be.true expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
}) expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false
}) done()
describe('toVinylArraySync()', function () {
it('should produce a an array of vinylfiles', function () {
let localStringArray = ['string1', 'string2', 'string3']
let localOptions = { filename: 'vinylfile2', base: '/someDir' }
let testResult = smartfile.memory.toVinylArraySync(localStringArray, localOptions)
expect(testResult).to.be.a('array')
expect(testResult.length === 3).to.be.true
for (let myKey in testResult) {
expect(testResult[myKey] instanceof vinyl).to.be.true
}
})
})
describe('vinylToStringSync()', function () {
it('should produce a String from vinyl file', function () {
let localString = smartfile.memory.vinylToStringSync(new vinyl({
base: '/',
path: '/test.txt',
contents: new Buffer('myString')
}))
expect(localString).equal('myString')
})
})
describe('toFs()', function () {
it('should write a file to disk and return a promise', function (done) {
let localString = 'myString'
smartfile.memory.toFs(
localString,
path.join(process.cwd(), './test/temp/testMemToFs.txt')
).then(done)
})
})
describe('toFsSync()', function () {
it('should write a file to disk and return true if successfull', function () {
let localString = 'myString'
smartfile.memory.toFsSync(
localString,
path.join(process.cwd(), './test/temp/testMemToFsSync.txt')
)
})
}) })
})
it('smartfile.fs.removeManySync -> should remove and array of single files synchronouly', function () {
smartfile.fs.removeManySync([ './test/temp/testfile1.txt', './test/temp/testfile2.txt' ])
expect(smartfile.fs.fileExistsSync('./test/temp/testfile1.txt')).to.be.false
expect(smartfile.fs.fileExistsSync('./test/temp/testfile2.txt')).to.be.false
})
}) })
})
describe('.remote', function () { describe('.interpreter', function () {
describe('.toString()', function () { describe('.filetype()', function () {
it('should load a remote file to a variable', function (done) { it('should get the file type from a string', function () {
this.timeout(5000) expect(smartfile.interpreter.filetype('./somefolder/data.json')).equal('json')
smartfile.remote.toString( })
'https://raw.githubusercontent.com/pushrocks/smartfile/master/test/mytest.txt'
).then(function (responseString) {
expect(responseString).to.equal('Some TestString &&%$')
done()
})
})
it('should reject a Promise when the link is false', function (done) {
this.timeout(10000)
smartfile.remote.toString('https://push.rocks/doesnotexist.txt')
.then(
function () {
throw new Error('this test should not be resolved')
},
function () {
done()
}
)
})
})
}) })
})
describe('.fs', function () {
describe('.toObjectSync()', function () {
it('should read an ' + '.yaml' + ' file to an object', function () {
let testData = smartfile.fs.toObjectSync('./test/mytest.yaml')
expect(testData).have.property('key1', 'this works')
expect(testData).have.property('key2', 'this works too')
})
it('should state unknown file type for unknown file types', function () {
let testData = smartfile.fs.toObjectSync('./test/mytest.txt')
})
it('should read an ' + '.json' + ' file to an object', function () {
let testData = smartfile.fs.toObjectSync('./test/mytest.json')
expect(testData).have.property('key1', 'this works')
expect(testData).have.property('key2', 'this works too')
})
})
describe('.toStringSync()', function () {
it('should read a file to a string', function () {
expect(smartfile.fs.toStringSync('./test/mytest.txt'))
.to.equal('Some TestString &&%$')
})
})
describe('.toVinylSync', function () {
it('should read an ' + '.json OR .yaml' + ' file to an ' + 'vinyl file object', function () {
let testData = smartfile.fs.toVinylSync('./test/mytest.json')
expect(vinyl.isVinyl(testData)).to.be.true
})
})
})
describe('.memory', function () {
describe('.toGulpStream()', function () {
it('should produce a valid gulp stream', function () {
let localArray = [ 'test1', 'test2', 'test3' ]
smartfile.memory.toGulpStream(localArray)
})
})
describe('toVinylFileSync()', function () {
it('should produce a vinylFile', function () {
let localString = 'myString'
let localOptions = { filename: 'vinylfile2', base: '/someDir' }
expect(smartfile.memory.toVinylFileSync(localString, localOptions) instanceof vinyl).to.be.true
})
})
describe('toVinylArraySync()', function () {
it('should produce a an array of vinylfiles', function () {
let localStringArray = [ 'string1', 'string2', 'string3' ]
let localOptions = { filename: 'vinylfile2', base: '/someDir' }
let testResult = smartfile.memory.toVinylArraySync(localStringArray, localOptions)
expect(testResult).to.be.a('array')
expect(testResult.length === 3).to.be.true
for (let myKey in testResult) {
expect(testResult[ myKey ] instanceof vinyl).to.be.true
}
})
})
describe('vinylToStringSync()', function () {
it('should produce a String from vinyl file', function () {
let localString = smartfile.memory.vinylToStringSync(new vinyl({
base: '/',
path: '/test.txt',
contents: new Buffer('myString')
}))
expect(localString).equal('myString')
})
})
describe('toFs()', function () {
it('should write a file to disk and return a promise', function (done) {
let localString = 'myString'
smartfile.memory.toFs(
localString,
path.join(process.cwd(), './test/temp/testMemToFs.txt')
).then(done)
})
})
describe('toFsSync()', function () {
it('should write a file to disk and return true if successfull', function () {
let localString = 'myString'
smartfile.memory.toFsSync(
localString,
path.join(process.cwd(), './test/temp/testMemToFsSync.txt')
)
})
})
})
describe('.remote', function () {
describe('.toString()', function () {
it('should load a remote file to a variable', function (done) {
this.timeout(5000)
smartfile.remote.toString(
'https://raw.githubusercontent.com/pushrocks/smartfile/master/test/mytest.txt'
).then(function (responseString) {
expect(responseString).to.equal('Some TestString &&%$')
done()
})
})
it('should reject a Promise when the link is false', function (done) {
this.timeout(10000)
smartfile.remote.toString('https://push.rocks/doesnotexist.txt')
.then(
function () {
throw new Error('this test should not be resolved')
},
function () {
done()
}
)
})
})
})
}) })

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 =============================
@ -12,15 +15,15 @@ import * as memory from './smartfile.memory'
* @param filePath * @param filePath
* @returns {boolean} * @returns {boolean}
*/ */
export let fileExistsSync = function(filePath): boolean { export let fileExistsSync = function (filePath): boolean {
let fileExistsBool: boolean = false let fileExistsBool: boolean = false
try { try {
plugins.fsExtra.readFileSync(filePath) plugins.fsExtra.readFileSync(filePath)
fileExistsBool = true fileExistsBool = true
} catch (err) { } catch (err) {
fileExistsBool = false fileExistsBool = false
} }
return fileExistsBool return fileExistsBool
} }
/** /**
@ -28,26 +31,26 @@ export let fileExistsSync = function(filePath): boolean {
* @param filePath * @param filePath
* @returns {any} * @returns {any}
*/ */
export let fileExists = function(filePath){ export let fileExists = function (filePath) {
let done = plugins.q.defer() let done = plugins.q.defer()
plugins.fs.access(filePath, 4, function (err) { plugins.fs.access(filePath, 4, function (err) {
err ? done.reject(err) : done.resolve() err ? done.reject(err) : done.resolve()
}) })
return done.promise return done.promise
} }
/** /**
* Checks if given path points to an existing directory * Checks if given path points to an existing directory
*/ */
export let isDirectory = function(pathArg): boolean{ export let isDirectory = function (pathArg): boolean {
return plugins.fsExtra.statSync(pathArg).isDirectory() return plugins.fsExtra.statSync(pathArg).isDirectory()
} }
/** /**
* Checks if a given path points to an existing file * Checks if a given path points to an existing file
*/ */
export let isFile = function(pathArg): boolean{ export let isFile = function (pathArg): boolean {
return plugins.fsExtra.statSync(pathArg).isFile() return plugins.fsExtra.statSync(pathArg).isFile()
} }
/*=============================================================== /*===============================================================
@ -57,36 +60,36 @@ export let isFile = function(pathArg): boolean{
/** /**
* copies a file from A to B on the local disk * copies a file from A to B on the local disk
*/ */
export let copy = function(fromArg: string, toArg: string){ export let copy = function (fromArg: string, toArg: string) {
let done = plugins.q.defer() let done = plugins.q.defer()
plugins.fsExtra.copy(fromArg,toArg,{},function(){ plugins.fsExtra.copy(fromArg, toArg, {}, function () {
done.resolve() done.resolve()
}) })
return done.promise return done.promise
} }
/** /**
* copies a file SYNCHRONOUSLY from A to B on the local disk * copies a file SYNCHRONOUSLY from A to B on the local disk
*/ */
export let copySync = function(fromArg: string,toArg: string): boolean{ export let copySync = function (fromArg: string, toArg: string): boolean {
plugins.fsExtra.copySync(fromArg,toArg) plugins.fsExtra.copySync(fromArg, toArg)
return true return true
} }
/** /**
* ensures that a directory is in place * ensures that a directory is in place
*/ */
export let ensureDir = (dirPathArg: string) => { export let ensureDir = (dirPathArg: string) => {
let done = plugins.q.defer() let done = plugins.q.defer()
plugins.fsExtra.ensureDir(dirPathArg,done.resolve) plugins.fsExtra.ensureDir(dirPathArg, done.resolve)
return done.promise return done.promise
} }
/** /**
* ensures that a directory is in place * ensures that a directory is in place
*/ */
export let ensureDirSync = (dirPathArg: string) => { export let ensureDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg) plugins.fsExtra.ensureDirSync(dirPathArg)
} }
/** /**
@ -94,11 +97,11 @@ export let ensureDirSync = (dirPathArg: string) => {
* @executes ASYNC * @executes ASYNC
*/ */
export let ensureEmptyDir = (dirPathArg: string) => { export let ensureEmptyDir = (dirPathArg: string) => {
let done = plugins.q.defer() let done = plugins.q.defer()
plugins.fsExtra.ensureDir(dirPathArg,() => { plugins.fsExtra.ensureDir(dirPathArg, () => {
plugins.fsExtra.emptyDir(dirPathArg, done.resolve) plugins.fsExtra.emptyDir(dirPathArg, done.resolve)
}) })
return done.promise return done.promise
} }
/** /**
@ -106,8 +109,8 @@ export let ensureEmptyDir = (dirPathArg: string) => {
* @executes SYNC * @executes SYNC
*/ */
export let ensureEmptyDirSync = (dirPathArg: string) => { export let ensureEmptyDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg) plugins.fsExtra.ensureDirSync(dirPathArg)
plugins.fsExtra.emptyDirSync(dirPathArg) plugins.fsExtra.emptyDirSync(dirPathArg)
} }
/** /**
@ -118,10 +121,10 @@ export let ensureEmptyDirSync = (dirPathArg: string) => {
* @exec ASYNC * @exec ASYNC
*/ */
export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => { export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => {
let done = plugins.q.defer<void>() let done = plugins.q.defer<void>()
ensureFileSync(filePathArg, initFileStringArg) ensureFileSync(filePathArg, initFileStringArg)
done.resolve() done.resolve()
return done.promise return done.promise
} }
/** /**
@ -132,50 +135,50 @@ export let ensureFile = (filePathArg, initFileStringArg): Promise<void> => {
* @exec SYNC * @exec SYNC
*/ */
export let ensureFileSync = (filePathArg: string, initFileStringArg: string): void => { export let ensureFileSync = (filePathArg: string, initFileStringArg: string): void => {
if (fileExistsSync(filePathArg)) { if (fileExistsSync(filePathArg)) {
return null return null
} else { } else {
memory.toFsSync(initFileStringArg, filePathArg) memory.toFsSync(initFileStringArg, filePathArg)
} }
} }
/** /**
* removes a file or folder from local disk * removes a file or folder from local disk
*/ */
export let remove = function(pathArg: string): Promise<void> { export let remove = function (pathArg: string): Promise<void> {
let done = plugins.q.defer<void>() let done = plugins.q.defer<void>()
plugins.fsExtra.remove(pathArg,function(){ plugins.fsExtra.remove(pathArg, function () {
done.resolve() done.resolve()
}) })
return done.promise return done.promise
} }
/** /**
* removes a file SYNCHRONOUSLY from local disk * removes a file SYNCHRONOUSLY from local disk
*/ */
export let removeSync = function(pathArg: string): boolean{ export let removeSync = function (pathArg: string): boolean {
plugins.fsExtra.removeSync(pathArg) plugins.fsExtra.removeSync(pathArg)
return true return true
} }
/** /**
* removes an array of filePaths from disk * removes an array of filePaths from disk
*/ */
export let removeMany = function(filePathArrayArg: string[]){ export let removeMany = function (filePathArrayArg: string[]) {
let promiseArray: Promise<void>[] = [] let promiseArray: Promise<void>[] = []
for (let filePath of filePathArrayArg) { for (let filePath of filePathArrayArg) {
promiseArray.push(remove(filePath)) promiseArray.push(remove(filePath))
} }
return Promise.all(promiseArray) return Promise.all(promiseArray)
} }
/** /**
* like removeFilePathArray but SYNCHRONOUSLY * like removeFilePathArray but SYNCHRONOUSLY
*/ */
export let removeManySync = function(filePathArrayArg: string[]): void { export let removeManySync = function (filePathArrayArg: string[]): void {
for (let filePath of filePathArrayArg) { for (let filePath of filePathArrayArg) {
removeSync(filePath) removeSync(filePath)
} }
} }
/*=============================================================== /*===============================================================
@ -188,11 +191,11 @@ export let removeManySync = function(filePathArrayArg: string[]): void {
* @param fileTypeArg * @param fileTypeArg
* @returns {any} * @returns {any}
*/ */
export let toObjectSync = function(filePathArg,fileTypeArg?) { export let toObjectSync = function (filePathArg, fileTypeArg?) {
let fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8') let fileString = plugins.fsExtra.readFileSync(filePathArg, 'utf8')
let fileType let fileType
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileInterpreter.filetype(filePathArg) fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileInterpreter.filetype(filePathArg)
return SmartfileInterpreter.objectFile(fileString,fileType) return SmartfileInterpreter.objectFile(fileString, fileType)
} }
/** /**
@ -200,10 +203,23 @@ export let toObjectSync = function(filePathArg,fileTypeArg?) {
* @param filePath * @param filePath
* @returns {string|Buffer|any} * @returns {string|Buffer|any}
*/ */
export let toStringSync = function(filePath) { export let toStringSync = function (filePath: string) {
let fileString let fileString = plugins.fsExtra.readFileSync(filePath, 'utf8')
fileString = plugins.fsExtra.readFileSync(filePath, 'utf8') 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(
plugins.path.join(dirPathArg, filePath)
))
}))
}
return smartfileArray
} }
/** /**
@ -212,8 +228,8 @@ export let toStringSync = function(filePath) {
* @param options * @param options
* @returns {number} * @returns {number}
*/ */
export let toVinylSync = function(filePathArg,options = {}) { export let toVinylSync = function (filePathArg, options = {}) {
return plugins.vinylFile.readSync(filePathArg,options) return plugins.vinylFile.readSync(filePathArg, options)
} }
/** /**
@ -221,92 +237,92 @@ export let toVinylSync = function(filePathArg,options = {}) {
* @param path * @param path
* @returns {any} * @returns {any}
*/ */
export let requireReload = function(path: string){ export let requireReload = function (path: string) {
return plugins.requireReload(path) return plugins.requireReload(path)
} }
/** /**
* lists Folders in a directory on local disk * lists Folders in a directory on local disk
* @returns Promise * @returns Promise
*/ */
export let listFolders = function(pathArg: string,regexFilter?: RegExp){ export let listFolders = function (pathArg: string, regexFilter?: RegExp) {
let done = plugins.q.defer() let done = plugins.q.defer()
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory()
})
if (regexFilter) {
folderArray = folderArray.filter((fileItem) => {
return regexFilter.test(fileItem)
}) })
if (regexFilter) { }
folderArray = folderArray.filter((fileItem) => { done.resolve(folderArray)
return regexFilter.test(fileItem) return done.promise
})
}
done.resolve(folderArray)
return done.promise
} }
/** /**
* lists Folders SYNCHRONOUSLY in a directory on local disk * lists Folders SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
*/ */
export let listFoldersSync = function(pathArg: string,regexFilter?: RegExp): string[]{ export let listFoldersSync = function (pathArg: string, regexFilter?: RegExp): string[] {
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory()
})
if (regexFilter) {
folderArray = folderArray.filter((fileItem) => {
return regexFilter.test(fileItem)
}) })
if (regexFilter) { }
folderArray = folderArray.filter((fileItem) => { return folderArray
return regexFilter.test(fileItem)
})
}
return folderArray
} }
/** /**
* lists Files in a directory on local disk * lists Files in a directory on local disk
* @returns Promise * @returns Promise
*/ */
export let listFiles = function(pathArg: string, regexFilter?: RegExp){ export let listFiles = function (pathArg: string, regexFilter?: RegExp) {
let done = plugins.q.defer() let done = plugins.q.defer()
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile()
})
if (regexFilter) {
fileArray = fileArray.filter((fileItem) => {
return regexFilter.test(fileItem)
}) })
if (regexFilter) { }
fileArray = fileArray.filter((fileItem) => { done.resolve(fileArray)
return regexFilter.test(fileItem) return done.promise
})
}
done.resolve(fileArray)
return done.promise
} }
/** /**
* lists Files SYNCHRONOUSLY in a directory on local disk * lists Files SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
*/ */
export let listFilesSync = function(pathArg: string, regexFilter?: RegExp): string[]{ export let listFilesSync = function (pathArg: string, regexFilter?: RegExp): string[] {
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile()
})
if (regexFilter) {
fileArray = fileArray.filter((fileItem) => {
return regexFilter.test(fileItem)
}) })
if (regexFilter) { }
fileArray = fileArray.filter((fileItem) => { return fileArray
return regexFilter.test(fileItem)
})
}
return fileArray
} }
/** /**
* lists all items (folders AND files) in a directory on local disk * lists all items (folders AND files) in a directory on local disk
* @returns Promise<string[]> * @returns Promise<string[]>
*/ */
export let listAllItems = function(pathArg: string, regexFilter?: RegExp): Promise<string[]> { export let listAllItems = function (pathArg: string, regexFilter?: RegExp): Promise<string[]> {
let done = plugins.q.defer<string[]>() let done = plugins.q.defer<string[]>()
let allItmesArray = plugins.fsExtra.readdirSync(pathArg) let allItmesArray = plugins.fsExtra.readdirSync(pathArg)
if (regexFilter) { if (regexFilter) {
allItmesArray = allItmesArray.filter((fileItem) => { allItmesArray = allItmesArray.filter((fileItem) => {
return regexFilter.test(fileItem) return regexFilter.test(fileItem)
}) })
}; };
done.resolve(allItmesArray) done.resolve(allItmesArray)
return done.promise return done.promise
} }
/** /**
@ -314,16 +330,16 @@ export let listAllItems = function(pathArg: string, regexFilter?: RegExp): Promi
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
* @executes SYNC * @executes SYNC
*/ */
export let listAllItemsSync = function(pathArg: string, regexFilter?: RegExp): string[]{ export let listAllItemsSync = function (pathArg: string, regexFilter?: RegExp): string[] {
let allItmesArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { let allItmesArray = plugins.fsExtra.readdirSync(pathArg).filter(function (file) {
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile() return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile()
})
if (regexFilter) {
allItmesArray = allItmesArray.filter((fileItem) => {
return regexFilter.test(fileItem)
}) })
if (regexFilter) { }
allItmesArray = allItmesArray.filter((fileItem) => { return allItmesArray
return regexFilter.test(fileItem)
})
}
return allItmesArray
} }
/** /**
@ -332,25 +348,25 @@ export let listAllItemsSync = function(pathArg: string, regexFilter?: RegExp): s
* @returns Promise<string[]> string array with the absolute paths of all matching files * @returns Promise<string[]> string array with the absolute paths of all matching files
*/ */
export let listFileTree = (dirPathArg: string, miniMatchFilter: string): Promise<string[]> => { export let listFileTree = (dirPathArg: string, miniMatchFilter: string): Promise<string[]> => {
let done = plugins.q.defer<string[]>() let done = plugins.q.defer<string[]>()
// handle absolute miniMatchFilter // handle absolute miniMatchFilter
let dirPath: string let dirPath: string
if (plugins.path.isAbsolute(miniMatchFilter)) { if (plugins.path.isAbsolute(miniMatchFilter)) {
dirPath = '/' dirPath = '/'
} else { } else {
dirPath = dirPathArg dirPath = dirPathArg
} }
let options = { let options = {
cwd: dirPath cwd: dirPath
}
plugins.glob(miniMatchFilter, options, (err, files: string[]) => {
if (err) {
console.log(err)
done.reject(err)
} }
plugins.glob(miniMatchFilter,options,(err,files: string[]) => { done.resolve(files)
if (err) { })
console.log(err) return done.promise
done.reject(err)
}
done.resolve(files)
})
return done.promise
} }

View File

@ -9,7 +9,13 @@
"@types/chai" "*" "@types/chai" "*"
"@types/promises-a-plus" "*" "@types/promises-a-plus" "*"
"@types/chai@*", "@types/chai@^3.4.34": "@types/chai-string@^1.1.30":
version "1.1.30"
resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.1.30.tgz#4d8744b31a5a2295fc01c981ed1e2d4c8a070f0a"
dependencies:
"@types/chai" "*"
"@types/chai@*", "@types/chai@^3.4.35":
version "3.4.35" version "3.4.35"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.35.tgz#e8d65f83492d2944f816fc620741821c28a8c900" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.35.tgz#e8d65f83492d2944f816fc620741821c28a8c900"
@ -84,6 +90,10 @@ chai-as-promised@^6.0.0:
dependencies: dependencies:
check-error "^1.0.2" check-error "^1.0.2"
chai-string@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.3.0.tgz#df6139f294391b1035be5606f60a843b3a5041e7"
chai@^3.5.0: chai@^3.5.0:
version "3.5.0" version "3.5.0"
resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247" resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"
@ -209,9 +219,9 @@ isarray@~1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
js-yaml@^3.7.0: js-yaml@^3.8.2:
version "3.8.1" version "3.8.2"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.1.tgz#782ba50200be7b9e5a8537001b7804db3ad02628" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.2.tgz#02d3e2c0f6beab20248d412c352203827d786721"
dependencies: dependencies:
argparse "^1.0.7" argparse "^1.0.7"
esprima "^3.1.1" esprima "^3.1.1"
@ -309,23 +319,25 @@ shelljs@^0.7.4, shelljs@^0.7.5:
interpret "^1.0.0" interpret "^1.0.0"
rechoir "^0.6.2" rechoir "^0.6.2"
smartchai@^1.0.1: smartchai@^1.0.3:
version "1.0.1" version "1.0.3"
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.1.tgz#cde7776212fa5145d62dc4195405929807a3e0e5" resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.3.tgz#de6d010bb8b5aef24cb70b31a5f5334e8c41b72f"
dependencies: dependencies:
"@types/chai" "^3.4.34" "@types/chai" "^3.4.35"
"@types/chai-as-promised" "0.0.29" "@types/chai-as-promised" "0.0.29"
"@types/chai-string" "^1.1.30"
chai "^3.5.0" chai "^3.5.0"
chai-as-promised "^6.0.0" chai-as-promised "^6.0.0"
chai-string "^1.3.0"
smartpath@^3.2.7: smartpath@^3.2.8:
version "3.2.7" version "3.2.8"
resolved "https://registry.yarnpkg.com/smartpath/-/smartpath-3.2.7.tgz#01688f01f9abbaa418dc2be561d9b0eaef3e5782" resolved "https://registry.yarnpkg.com/smartpath/-/smartpath-3.2.8.tgz#4834bd3a8bae2295baacadba23c87a501952f940"
dependencies: dependencies:
home "^1.0.1" home "^1.0.1"
typings-global "^1.0.14" typings-global "^1.0.14"
smartq@^1.0.4, smartq@^1.1.0: smartq@^1.1.0, smartq@^1.1.1:
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.1.tgz#efb358705260d41ae18aef7ffd815f7b6fe17dd3" resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.1.tgz#efb358705260d41ae18aef7ffd815f7b6fe17dd3"
dependencies: dependencies: