Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
bafc22403a | |||
94303b76b3 | |||
eeab2cf0cd | |||
ab76cae75e | |||
f39daca6aa | |||
e70db71ec4 | |||
50ef41d5d4 | |||
2a417ba18f | |||
3516189940 | |||
10e3628a89 | |||
86eafe4568 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,12 +1,7 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
pages/
|
||||||
|
|
||||||
ts/*.js
|
|
||||||
ts/*.js.map
|
|
||||||
ts/typings/
|
|
||||||
|
|
||||||
test/temp/
|
test/temp/
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ testSTABLE:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
|
environment: npm_registry
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci publish
|
||||||
only:
|
only:
|
||||||
|
25
dist/smartfile.fs.d.ts
vendored
25
dist/smartfile.fs.d.ts
vendored
@ -12,7 +12,7 @@ export declare let fileExistsSync: (filePath: any) => boolean;
|
|||||||
* @param filePath
|
* @param filePath
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export declare let fileExists: (filePath: any) => plugins.Q.Promise<{}>;
|
export declare let fileExists: (filePath: any) => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
* Checks if given path points to an existing directory
|
* Checks if given path points to an existing directory
|
||||||
*/
|
*/
|
||||||
@ -24,7 +24,7 @@ export declare let isFile: (pathArg: any) => boolean;
|
|||||||
/**
|
/**
|
||||||
* ensures that a directory is in place
|
* ensures that a directory is in place
|
||||||
*/
|
*/
|
||||||
export declare let ensureDir: (dirPathArg: string) => plugins.Q.Promise<{}>;
|
export declare let ensureDir: (dirPathArg: string) => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
* ensures that a directory is in place
|
* ensures that a directory is in place
|
||||||
*/
|
*/
|
||||||
@ -32,7 +32,7 @@ export declare let ensureDirSync: (dirPathArg: string) => void;
|
|||||||
/**
|
/**
|
||||||
* copies a file from A to B on the local disk
|
* copies a file from A to B on the local disk
|
||||||
*/
|
*/
|
||||||
export declare let copy: (fromArg: string, toArg: string) => plugins.Q.Promise<{}>;
|
export declare let copy: (fromArg: string, toArg: string) => plugins.q.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
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,7 @@ export declare let copySync: (fromArg: string, toArg: string) => boolean;
|
|||||||
/**
|
/**
|
||||||
* removes a file or folder from local disk
|
* removes a file or folder from local disk
|
||||||
*/
|
*/
|
||||||
export declare let remove: (pathArg: string) => plugins.Q.Promise<{}>;
|
export declare let remove: (pathArg: string) => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
* removes a file SYNCHRONOUSLY from local disk
|
* removes a file SYNCHRONOUSLY from local disk
|
||||||
*/
|
*/
|
||||||
@ -82,7 +82,7 @@ export declare let requireReload: (path: string) => any;
|
|||||||
* lists Folders in a directory on local disk
|
* lists Folders in a directory on local disk
|
||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
export declare let listFolders: (pathArg: string, regexFilter?: RegExp) => plugins.Q.Promise<{}>;
|
export declare let listFolders: (pathArg: string, regexFilter?: RegExp) => plugins.q.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
|
||||||
@ -92,7 +92,7 @@ export declare let listFoldersSync: (pathArg: string, regexFilter?: RegExp) => s
|
|||||||
* lists Files in a directory on local disk
|
* lists Files in a directory on local disk
|
||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
export declare let listFiles: (pathArg: string, regexFilter?: RegExp) => plugins.Q.Promise<{}>;
|
export declare let listFiles: (pathArg: string, regexFilter?: RegExp) => plugins.q.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
|
||||||
@ -100,12 +100,17 @@ export declare let listFiles: (pathArg: string, regexFilter?: RegExp) => plugins
|
|||||||
export declare let listFilesSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
export declare let listFilesSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
||||||
/**
|
/**
|
||||||
* 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
|
* @returns Promise<string[]>
|
||||||
*/
|
*/
|
||||||
export declare let listAllItems: (pathArg: string, regexFilter?: RegExp) => plugins.Q.Promise<{}>;
|
export declare let listAllItems: (pathArg: string, regexFilter?: RegExp) => plugins.q.Promise<string[]>;
|
||||||
/**
|
/**
|
||||||
* lists all items (folders AND files) SYNCHRONOUSLY in a directory on local disk
|
* lists all items (folders AND files) in a directory on local disk
|
||||||
* @returns an array with the folder names as strings
|
* @returns an array with the folder names as strings
|
||||||
|
* @executes SYNC
|
||||||
*/
|
*/
|
||||||
export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
||||||
export declare let listFileTree: (dirPath: string, miniMatchFilter: string) => plugins.Q.Promise<{}>;
|
/**
|
||||||
|
* lists a file tree using a miniMatch filter
|
||||||
|
* @returns Promise<string[]> string array with the absolute paths of all matching files
|
||||||
|
*/
|
||||||
|
export declare let listFileTree: (dirPath: string, miniMatchFilter: string) => plugins.q.Promise<string[]>;
|
||||||
|
71
dist/smartfile.fs.js
vendored
71
dist/smartfile.fs.js
vendored
File diff suppressed because one or more lines are too long
9
dist/smartfile.memory.d.ts
vendored
9
dist/smartfile.memory.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
/// <reference types="vinyl" />
|
|
||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import "typings-global";
|
import "typings-global";
|
||||||
import plugins = require("./smartfile.plugins");
|
import plugins = require("./smartfile.plugins");
|
||||||
@ -9,7 +8,7 @@ import plugins = require("./smartfile.plugins");
|
|||||||
* @returns stream.Readable
|
* @returns stream.Readable
|
||||||
* @TODO: make it async;
|
* @TODO: make it async;
|
||||||
*/
|
*/
|
||||||
export declare let toGulpStream: (fileArg: string | string[] | plugins.vinyl | plugins.vinyl[], baseArg?: string) => any;
|
export declare let toGulpStream: (fileArg: any, baseArg?: string) => any;
|
||||||
/**
|
/**
|
||||||
* converts file to Object
|
* converts file to Object
|
||||||
* @param fileStringArg
|
* @param fileStringArg
|
||||||
@ -26,7 +25,7 @@ export declare let toVinylFileSync: (fileArg: string, optionsArg?: {
|
|||||||
filename?: string;
|
filename?: string;
|
||||||
base?: string;
|
base?: string;
|
||||||
relPath?: string;
|
relPath?: string;
|
||||||
}) => plugins.vinyl;
|
}) => any;
|
||||||
/**
|
/**
|
||||||
* takes a string array and some options and returns a vinylfile array
|
* takes a string array and some options and returns a vinylfile array
|
||||||
* @param arrayArg
|
* @param arrayArg
|
||||||
@ -40,12 +39,12 @@ export declare let toVinylArraySync: (arrayArg: string[], optionsArg?: {
|
|||||||
/**
|
/**
|
||||||
* takes a vinylFile object and converts it to String
|
* takes a vinylFile object and converts it to String
|
||||||
*/
|
*/
|
||||||
export declare let toStringSync: (fileArg: plugins.vinyl) => string;
|
export declare let toStringSync: (fileArg: any) => any;
|
||||||
/**
|
/**
|
||||||
* writes string or vinyl file to disk.
|
* writes string or vinyl file to disk.
|
||||||
* @param fileArg
|
* @param fileArg
|
||||||
* @param fileNameArg
|
* @param fileNameArg
|
||||||
* @param fileBaseArg
|
* @param fileBaseArg
|
||||||
*/
|
*/
|
||||||
export declare let toFs: (fileContentArg: string | plugins.vinyl, filePathArg: any) => plugins.Q.Promise<{}>;
|
export declare let toFs: (fileContentArg: any, filePathArg: any) => plugins.q.Promise<{}>;
|
||||||
export declare let toFsSync: (fileArg: any, filePathArg: string) => void;
|
export declare let toFsSync: (fileArg: any, filePathArg: string) => void;
|
||||||
|
8
dist/smartfile.memory.js
vendored
8
dist/smartfile.memory.js
vendored
File diff suppressed because one or more lines are too long
9
dist/smartfile.plugins.d.ts
vendored
9
dist/smartfile.plugins.d.ts
vendored
@ -1,14 +1,15 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
export import beautylog = require("beautylog");
|
export import beautylog = require("beautylog");
|
||||||
export declare let fs: any;
|
export import fs = require("fs");
|
||||||
|
export import fsExtra = require("fs-extra");
|
||||||
export declare let gulp: any;
|
export declare let gulp: any;
|
||||||
export import glob = require("glob");
|
export declare let glob: any;
|
||||||
export declare let g: {
|
export declare let g: {
|
||||||
remoteSrc: any;
|
remoteSrc: any;
|
||||||
};
|
};
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import Q = require("q");
|
export import q = require("q");
|
||||||
export import vinyl = require("vinyl");
|
export declare let vinyl: any;
|
||||||
export declare let vinylFile: any;
|
export declare let vinylFile: any;
|
||||||
export declare let yaml: any;
|
export declare let yaml: any;
|
||||||
export declare let request: any;
|
export declare let request: any;
|
||||||
|
7
dist/smartfile.plugins.js
vendored
7
dist/smartfile.plugins.js
vendored
@ -1,17 +1,18 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.fs = require("fs-extra");
|
exports.fs = require("fs");
|
||||||
|
exports.fsExtra = require("fs-extra");
|
||||||
exports.gulp = require("gulp");
|
exports.gulp = require("gulp");
|
||||||
exports.glob = require("glob");
|
exports.glob = require("glob");
|
||||||
exports.g = {
|
exports.g = {
|
||||||
remoteSrc: require("gulp-remote-src")
|
remoteSrc: require("gulp-remote-src")
|
||||||
};
|
};
|
||||||
exports.path = require("path");
|
exports.path = require("path");
|
||||||
exports.Q = require("q");
|
exports.q = require("q");
|
||||||
exports.vinyl = require("vinyl");
|
exports.vinyl = require("vinyl");
|
||||||
exports.vinylFile = require("vinyl-file");
|
exports.vinylFile = require("vinyl-file");
|
||||||
exports.yaml = require("js-yaml");
|
exports.yaml = require("js-yaml");
|
||||||
exports.request = require("request");
|
exports.request = require("request");
|
||||||
exports.requireReload = require("require-reload");
|
exports.requireReload = require("require-reload");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGZpbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNwQyxVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3pCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQzFCLFNBQUMsR0FBRztJQUNYLFNBQVMsRUFBRSxPQUFPLENBQUMsaUJBQWlCLENBQUM7Q0FDeEMsQ0FBQztBQUNZLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsYUFBSyxXQUFXLE9BQU8sQ0FBQyxDQUFDO0FBQzVCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDO0FBQ2xDLFlBQUksR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFD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6
dist/smartfile.remote.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import "typings-global";
|
import "typings-global";
|
||||||
import plugins = require("./smartfile.plugins");
|
import plugins = require("./smartfile.plugins");
|
||||||
export declare let toFs: (from: string, toPath: string) => plugins.Q.Promise<{}>;
|
export declare let toFs: (from: string, toPath: string) => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param filePathArg
|
* @param filePathArg
|
||||||
@ -13,10 +13,10 @@ export declare let toGulpStreamSync: (filePathArg: string, baseArg: string) => a
|
|||||||
* @param fromArg
|
* @param fromArg
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export declare let toObject: (fromArg: string) => plugins.Q.Promise<{}>;
|
export declare let toObject: (fromArg: string) => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param fromArg
|
* @param fromArg
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export declare let toString: (fromArg: string) => plugins.Q.Promise<{}>;
|
export declare let toString: (fromArg: string) => plugins.q.Promise<{}>;
|
||||||
|
10
dist/smartfile.remote.js
vendored
10
dist/smartfile.remote.js
vendored
@ -3,8 +3,8 @@ require("typings-global");
|
|||||||
const plugins = require("./smartfile.plugins");
|
const plugins = require("./smartfile.plugins");
|
||||||
const SmartfileInterpreter = require("./smartfile.interpreter");
|
const SmartfileInterpreter = require("./smartfile.interpreter");
|
||||||
exports.toFs = function (from, toPath) {
|
exports.toFs = function (from, toPath) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.q.defer();
|
||||||
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
|
var stream = plugins.request(from).pipe(plugins.fsExtra.createWriteStream(toPath));
|
||||||
stream.on('finish', function () {
|
stream.on('finish', function () {
|
||||||
done.resolve(toPath);
|
done.resolve(toPath);
|
||||||
});
|
});
|
||||||
@ -27,7 +27,7 @@ exports.toGulpStreamSync = function (filePathArg, baseArg) {
|
|||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
exports.toObject = function (fromArg) {
|
exports.toObject = function (fromArg) {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||||
let returnObject;
|
let returnObject;
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
@ -49,7 +49,7 @@ exports.toObject = function (fromArg) {
|
|||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
exports.toString = (fromArg) => {
|
exports.toString = (fromArg) => {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
done.resolve(bodyString);
|
done.resolve(bodyString);
|
||||||
@ -63,4 +63,4 @@ exports.toString = (fromArg) => {
|
|||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLnJlbW90ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZmlsZS5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixNQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBQ2hELE1BQU8sb0JBQW9CLFdBQVcseUJBQXlCLENBQUMsQ0FBQztBQUV0RCxZQUFJLEdBQUcsVUFBUyxJQUFXLEVBQUMsTUFBYTt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EsZ0JBQVEsR0FBRyxDQUFDLE9BQWM7SUFDakMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixPQUFPLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLEVBQUUsVUFBVSxLQUFLLEVBQUUsUUFBUSxFQUFFLFVBQVU7UUFDOUQsRUFBRSxDQUFDLENBQUMsQ0FBQyxLQUFLLElBQUksUUFBUSxDQUFDLFVBQVUsSUFBSSxHQUFHLENBQUMsQ0FBQyxDQUFDO1lBQ3ZDLElBQUksQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDN0IsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsaUNBQWlDLEdBQUcsT0FBTyxDQUFDLENBQUM7WUFDckUsVUFBVSxHQUFHLFNBQVMsQ0FBQztZQUN2QixJQUFJLENBQUMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxDQUFDO1FBQzVCLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FBQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ==
|
@ -2,5 +2,8 @@
|
|||||||
"npmts":{
|
"npmts":{
|
||||||
"mode":"default",
|
"mode":"default",
|
||||||
"coverageTreshold":70
|
"coverageTreshold":70
|
||||||
|
},
|
||||||
|
"npmdocker":{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
23
package.json
23
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartfile",
|
"name": "smartfile",
|
||||||
"version": "4.0.11",
|
"version": "4.0.16",
|
||||||
"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",
|
||||||
@ -26,25 +26,26 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartfile",
|
"homepage": "https://gitlab.com/pushrocks/smartfile",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/glob": "^5.0.29",
|
"@types/fs-extra": "0.x.x",
|
||||||
"@types/q": "^0.0.27",
|
"@types/q": "0.x.x",
|
||||||
"beautylog": "^5.0.14",
|
"beautylog": "^5.0.23",
|
||||||
"fs-extra": "^0.30.0",
|
"fs-extra": "^0.30.0",
|
||||||
"glob": "^7.0.5",
|
"glob": "^7.0.6",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-remote-src": "^0.4.1",
|
"gulp-remote-src": "^0.4.1",
|
||||||
"js-yaml": "^3.6.1",
|
"js-yaml": "^3.6.1",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"request": "^2.73.0",
|
"request": "^2.74.0",
|
||||||
"require-reload": "0.2.2",
|
"require-reload": "0.2.2",
|
||||||
"typings-global": "^1.0.6",
|
"typings-global": "^1.0.14",
|
||||||
"vinyl": "^1.1.1",
|
"vinyl": "^1.2.0",
|
||||||
"vinyl-file": "^2.0.0"
|
"vinyl-file": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/should": "^8.1.29",
|
||||||
"gulp-function": "^1.3.6",
|
"gulp-function": "^1.3.6",
|
||||||
"npmts-g": "^5.2.6",
|
"npmts-g": "^5.2.8",
|
||||||
"should": "^9.0.2",
|
"should": "^11.1.0",
|
||||||
"typings-test": "^1.0.1"
|
"typings-test": "^1.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
import "typings-test";
|
import "typings-test";
|
||||||
import * as smartfile from "../dist/index";
|
import * as smartfile from "../dist/index";
|
||||||
let beautylog = require("beautylog");
|
import beautylog = require("beautylog");
|
||||||
let gulp = require("gulp");
|
let gulp = require("gulp");
|
||||||
let gFunction = require("gulp-function");
|
let gFunction = require("gulp-function");
|
||||||
import path = require("path");
|
import path = require("path");
|
||||||
|
@ -15,7 +15,7 @@ import SmartfileInterpreter = require("./smartfile.interpreter");
|
|||||||
export let fileExistsSync = function(filePath):boolean {
|
export let fileExistsSync = function(filePath):boolean {
|
||||||
let fileExistsBool:boolean = false;
|
let fileExistsBool:boolean = false;
|
||||||
try {
|
try {
|
||||||
plugins.fs.readFileSync(filePath);
|
plugins.fsExtra.readFileSync(filePath);
|
||||||
fileExistsBool = true
|
fileExistsBool = true
|
||||||
}
|
}
|
||||||
catch(err){
|
catch(err){
|
||||||
@ -30,7 +30,7 @@ export let fileExistsSync = function(filePath):boolean {
|
|||||||
* @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, plugins.fs.R_OK, function (err) {
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
err ? done.reject(err) : done.resolve();
|
err ? done.reject(err) : done.resolve();
|
||||||
});
|
});
|
||||||
@ -41,14 +41,14 @@ export let fileExists = function(filePath){
|
|||||||
* 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.fs.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.fs.statSync(pathArg).isFile();
|
return plugins.fsExtra.statSync(pathArg).isFile();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===============================================================
|
/*===============================================================
|
||||||
@ -59,8 +59,8 @@ export let isFile = function(pathArg):boolean{
|
|||||||
* 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.fs.ensureDir(dirPathArg,done.resolve);
|
plugins.fsExtra.ensureDir(dirPathArg,done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,15 +68,15 @@ export let ensureDir = (dirPathArg:string) => {
|
|||||||
* 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.fs.ensureDirSync(dirPathArg);
|
plugins.fsExtra.ensureDirSync(dirPathArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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){
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.q.defer();
|
||||||
plugins.fs.copy(fromArg,toArg,{},function(){
|
plugins.fsExtra.copy(fromArg,toArg,{},function(){
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
@ -86,7 +86,7 @@ export let copy = function(fromArg:string, toArg:string){
|
|||||||
* 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.fs.copySync(fromArg,toArg);
|
plugins.fsExtra.copySync(fromArg,toArg);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,8 +94,8 @@ export let copySync = function(fromArg:string,toArg:string):boolean{
|
|||||||
* removes a file or folder from local disk
|
* removes a file or folder from local disk
|
||||||
*/
|
*/
|
||||||
export let remove = function(pathArg:string){
|
export let remove = function(pathArg:string){
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.q.defer();
|
||||||
plugins.fs.remove(pathArg,function(){
|
plugins.fsExtra.remove(pathArg,function(){
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
@ -105,7 +105,7 @@ export let remove = function(pathArg:string){
|
|||||||
* 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.fs.removeSync(pathArg);
|
plugins.fsExtra.removeSync(pathArg);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ export let toGulpDestSync = function(folderPathArg:string){
|
|||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export let toObjectSync = function(filePathArg,fileTypeArg?) {
|
export let toObjectSync = function(filePathArg,fileTypeArg?) {
|
||||||
let fileString = plugins.fs.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);
|
||||||
@ -148,7 +148,7 @@ export let toObjectSync = function(filePathArg,fileTypeArg?) {
|
|||||||
*/
|
*/
|
||||||
export let toStringSync = function(filePath) {
|
export let toStringSync = function(filePath) {
|
||||||
let fileString;
|
let fileString;
|
||||||
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
fileString = plugins.fsExtra.readFileSync(filePath, "utf8");
|
||||||
return fileString;
|
return fileString;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,9 +176,9 @@ export let requireReload = function(path:string){
|
|||||||
* @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.fs.readdirSync(pathArg).filter(function(file) {
|
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
folderArray = folderArray.filter((fileItem) => {
|
folderArray = folderArray.filter((fileItem) => {
|
||||||
@ -194,8 +194,8 @@ export let listFolders = function(pathArg:string,regexFilter?:RegExp){
|
|||||||
* @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.fs.readdirSync(pathArg).filter(function(file) {
|
let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
folderArray = folderArray.filter((fileItem) => {
|
folderArray = folderArray.filter((fileItem) => {
|
||||||
@ -211,9 +211,9 @@ export let listFoldersSync = function(pathArg:string,regexFilter?:RegExp):string
|
|||||||
* @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.fs.readdirSync(pathArg).filter(function(file) {
|
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isFile();
|
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile();
|
||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
fileArray = fileArray.filter((fileItem) => {
|
fileArray = fileArray.filter((fileItem) => {
|
||||||
@ -229,8 +229,8 @@ export let listFiles = function(pathArg:string, regexFilter?:RegExp){
|
|||||||
* @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.fs.readdirSync(pathArg).filter(function(file) {
|
let fileArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isFile();
|
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile();
|
||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
fileArray = fileArray.filter((fileItem) => {
|
fileArray = fileArray.filter((fileItem) => {
|
||||||
@ -242,11 +242,11 @@ export let listFilesSync = function(pathArg:string, regexFilter?:RegExp):string[
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @returns Promise<string[]>
|
||||||
*/
|
*/
|
||||||
export let listAllItems = function(pathArg:string, regexFilter?:RegExp){
|
export let listAllItems = function(pathArg:string, regexFilter?:RegExp): plugins.q.Promise<string[]> {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.q.defer<string[]>();
|
||||||
let allItmesArray = plugins.fs.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);
|
||||||
@ -257,12 +257,13 @@ export let listAllItems = function(pathArg:string, regexFilter?:RegExp){
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lists all items (folders AND files) SYNCHRONOUSLY in a directory on local disk
|
* lists all items (folders AND files) in a directory on local disk
|
||||||
* @returns an array with the folder names as strings
|
* @returns an array with the folder names as strings
|
||||||
|
* @executes SYNC
|
||||||
*/
|
*/
|
||||||
export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):string[]{
|
export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):string[]{
|
||||||
let allItmesArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
let allItmesArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isFile();
|
return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isFile();
|
||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
allItmesArray = allItmesArray.filter((fileItem) => {
|
allItmesArray = allItmesArray.filter((fileItem) => {
|
||||||
@ -272,8 +273,12 @@ export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):stri
|
|||||||
return allItmesArray;
|
return allItmesArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
export let listFileTree = (dirPath:string, miniMatchFilter:string) => {
|
/**
|
||||||
let done = plugins.Q.defer();
|
* lists a file tree using a miniMatch filter
|
||||||
|
* @returns Promise<string[]> string array with the absolute paths of all matching files
|
||||||
|
*/
|
||||||
|
export let listFileTree = (dirPath:string, miniMatchFilter:string): plugins.q.Promise<string[]> => {
|
||||||
|
let done = plugins.q.defer<string[]>();
|
||||||
let options = {
|
let options = {
|
||||||
cwd:dirPath
|
cwd:dirPath
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ export let toStringSync = function(fileArg:plugins.vinyl){
|
|||||||
* @param fileBaseArg
|
* @param fileBaseArg
|
||||||
*/
|
*/
|
||||||
export let toFs = function(fileContentArg:string|vinyl,filePathArg){
|
export let toFs = function(fileContentArg:string|vinyl,filePathArg){
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.q.defer();
|
||||||
|
|
||||||
//function checks to abort if needed
|
//function checks to abort if needed
|
||||||
if (!fileContentArg || !filePathArg) throw new Error("expected valid arguments");
|
if (!fileContentArg || !filePathArg) throw new Error("expected valid arguments");
|
||||||
@ -111,7 +111,7 @@ export let toFs = function(fileContentArg:string|vinyl,filePathArg){
|
|||||||
} else if (typeof fileContentArg === "string") {
|
} else if (typeof fileContentArg === "string") {
|
||||||
fileString = fileContentArg;
|
fileString = fileContentArg;
|
||||||
}
|
}
|
||||||
plugins.fs.writeFile(filePath,fileString,"utf8",done.resolve);
|
plugins.fsExtra.writeFile(filePath,fileString,"utf8",done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -128,6 +128,6 @@ export let toFsSync = function(fileArg,filePathArg:string){
|
|||||||
} else if (typeof fileArg === "string") {
|
} else if (typeof fileArg === "string") {
|
||||||
fileString = fileArg;
|
fileString = fileArg;
|
||||||
}
|
}
|
||||||
plugins.fs.writeFileSync(filePath,fileString,"utf8");
|
plugins.fsExtra.writeFileSync(filePath,fileString,"utf8");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
export import beautylog = require("beautylog");
|
export import beautylog = require("beautylog");
|
||||||
export let fs = require("fs-extra");
|
export import fs = require("fs");
|
||||||
|
export import fsExtra = require("fs-extra");
|
||||||
export let gulp = require("gulp");
|
export let gulp = require("gulp");
|
||||||
export import glob = require("glob");
|
export let glob = require("glob");
|
||||||
export let g = {
|
export let g = {
|
||||||
remoteSrc: require("gulp-remote-src")
|
remoteSrc: require("gulp-remote-src")
|
||||||
};
|
};
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import Q = require("q");
|
export import q = require("q");
|
||||||
export import vinyl = require("vinyl");
|
export let vinyl = require("vinyl");
|
||||||
export let vinylFile = require("vinyl-file");
|
export let vinylFile = require("vinyl-file");
|
||||||
export let yaml = require("js-yaml");
|
export let yaml = require("js-yaml");
|
||||||
export let request = require("request");
|
export let request = require("request");
|
||||||
|
@ -3,8 +3,8 @@ import plugins = require("./smartfile.plugins");
|
|||||||
import SmartfileInterpreter = require("./smartfile.interpreter");
|
import SmartfileInterpreter = require("./smartfile.interpreter");
|
||||||
|
|
||||||
export let toFs = function(from:string,toPath:string) {
|
export let toFs = function(from:string,toPath:string) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.q.defer();
|
||||||
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
|
var stream = plugins.request(from).pipe(plugins.fsExtra.createWriteStream(toPath));
|
||||||
stream.on('finish',function(){
|
stream.on('finish',function(){
|
||||||
done.resolve(toPath);
|
done.resolve(toPath);
|
||||||
});
|
});
|
||||||
@ -29,7 +29,7 @@ export let toGulpStreamSync = function(filePathArg:string,baseArg:string){
|
|||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export let toObject = function(fromArg:string){
|
export let toObject = function(fromArg:string){
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||||
let returnObject;
|
let returnObject;
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
@ -50,7 +50,7 @@ export let toObject = function(fromArg:string){
|
|||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export let toString = (fromArg:string) => {
|
export let toString = (fromArg:string) => {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
done.resolve(bodyString);
|
done.resolve(bodyString);
|
||||||
|
Reference in New Issue
Block a user