Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
60a2a7fc69 | |||
5d898baadf | |||
9954ae4ba7 | |||
4b1f3d234b | |||
aed2c92b75 | |||
cb805898c9 | |||
c09fe29d99 | |||
a787836e56 | |||
287c2fa99f | |||
111b70aefb | |||
be91e22447 | |||
a337663830 | |||
2cbb14c515 | |||
68cc85b684 | |||
7e875212b5 | |||
372e00597c | |||
6e32af1c9b | |||
c60eac7787 | |||
581b9e21d3 | |||
0661744614 | |||
20a3fdba03 | |||
580cb95aa7 | |||
9a05df4200 | |||
9afe7c8a9e | |||
9aac47cae3 | |||
4e62bbeeea | |||
4a8df9c12f | |||
34d38cd3d4 | |||
834b22ed8d | |||
8e9b080004 | |||
d5d4d3ff67 | |||
075ffff713 | |||
641218e841 | |||
0ad455a483 | |||
cf6ea7e373 | |||
e9a38ccd2c | |||
8ddacf51ce | |||
3511f36b67 | |||
c5cfa79f14 | |||
32465d2556 | |||
9edab1b3ec | |||
c0ee2996ce | |||
f1d89beb06 | |||
0c0449527d | |||
3a76e9b572 | |||
3dddb80b43 | |||
2ba06f27dc | |||
228f855a39 | |||
55ac57a122 | |||
7da57901dd | |||
12500a0900 | |||
36371d9469 | |||
4e9874a639 | |||
e55e30bdb3 | |||
44aed02dd3 | |||
8d8d7e7ff4 | |||
57c90ca504 | |||
02b73f8bf8 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,6 +1,12 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
.settings/
|
||||||
.idea/
|
.idea/
|
||||||
|
coverage/
|
||||||
|
docs/
|
||||||
|
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
|
ts/typings/
|
||||||
|
|
||||||
|
test/temp/
|
||||||
|
|
||||||
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
coverage/
|
||||||
|
docs/
|
||||||
|
test/
|
||||||
|
ts/
|
11
.travis.yml
11
.travis.yml
@ -1,16 +1,15 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "4.1"
|
- 4
|
||||||
before_install:
|
- stable
|
||||||
- npm install -g tsd
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: npm@smart-coordination.com
|
email: npm@lossless.digital
|
||||||
api_key:
|
api_key:
|
||||||
secure: y7l1JyBDihAYxbqfuPAUXJfY+PC7RSSCkAtXtBIjPA6wytSBnz55te/Vdy8RFgVty6O/k4hHzrhgUJMSoWKmPuGQ5bMBgkyV9OI5PPp4uEUyy5UdcJZv3cZYpGGDRjLjCHP4pF7AHdRcDUMEiE5ZrDtmUH1SBLoRswieO0TKsiMr3u45yR6rHFoPnnw1YlatoAPpiuP3SLnCrIjQeSOS7y9SL6PpakiquJNtpseVOr60sp39L6vLAeqJ7xTjjNJk23LF/60lfiKtM7QFg9qqE7cxFUWJs7Zmgfg4/hGcU9XRfDfZQgSNntcdFczPejO5juv2KOb1tzH7EhXrWlcF1yd70RBdJbcOn7O6ctHjMCGrCSn6IQPzcNWNErFELfMLsjVQUxbfHSc0iA1JxcYWeXUivrStwVOa9ufuG2KZCQZyEjra3zPdCu9yrE30c/mTace7eJXPYTsNn2tmxvTnFoTWmeQ0xL9Iyz9zceADpxjYJoJ8r4XMDWxWga5G9OPaqCINHxjKhOX0C36YEjYTaeNMNHv6F6BPLdKwQ9SmklMtcyC312nJsXwKy+KYJSoY6WqMef9Zk3ez0o09W0UkSr0qiQkyYCoNm8b1L7VrYuccPH24GE0fn8QMWmeE5TBThYbEIdt6NBoYCDeocflUm5KBrImFGo1peeYS1aQnpoQ=
|
secure: wIOQHE7Jbck2j5lcv1Rc8T9/1wbHNGLxqJ6pttNZ+hG1+w77TYnjNYuGtM2xQCXitXSFDoogU8MpiYieOQHYypFgJ6Ns8MTeKIzNJSnlOWdCSN/lVptscT8pyC6qD4IBAyi8m5F2HoGQR+IzcdDBPjXLaPbH7jn8hc9rNY+LNktmYOXfOr37P40pxYrf16GLwrkjQIK8pbkdIbNA0D0k3apTGqw+HsneN2D/O/zAYaB3ojm40ttgPAGYF5PO5t6uqIbPFgIPkMWsO1HbV6I+vOAuIf0KYUqnR/YZd5yFcxFt3c+bfyc8/LP4vy5FyKMLXHe4IXIjXPYetOSiVHgMMYaxawU51OqwIKO+87FJ1TdaVmacMFO0wagl2QS0ceQBn8KBUhljHu/fDInK82uy15Iddk44EhnTx1MIxxgH5WMM6aQB2vuqnViPghs4nA0Y/Dz2U69267fhvmZvEWWUndz058EksHdZsIt5WCqQErI/dWLXMGom94CuZv6nkoVHCw8CO5dqVvfqUFL7Qyw59kRbiUPItFVoiV8ptLUX9tnQ5xBukNRkFX34ViM9YvBRlGt5e//f+cWjUpXFvbrwkqusXArplpxIaUSsQKh7XaMB5DcZ5jDDdjKzIMDf6QWsMTU1rjfQS5ZS3eV5LPy0UlfpDGK28oK2/o8fM+yydVk=
|
||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
repo: pushrocks/gulp-bootstrap
|
repo: pushrocks/smartfile
|
||||||
notifications:
|
notifications:
|
||||||
slack:
|
slack:
|
||||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
||||||
|
48
README.md
48
README.md
@ -1,39 +1,13 @@
|
|||||||
# gulp-bootstrap
|
# smartfile
|
||||||
works with gulp, but does nothing. Use it to bootstrap your own gulp plugin with TypeScript, Travis and npm.
|
make files easily accessible for processing in javascript.
|
||||||
|
|
||||||
### Buildstatus/Dependencies
|
## Status
|
||||||
[](https://travis-ci.org/pushrocks/gulp-bootstrap)
|
[](https://travis-ci.org/pushrocks/smartfile)
|
||||||
[](https://david-dm.org/pushrocks/gulp-bootstrap#info=devDependencies)
|
[](https://david-dm.org/pushrocks/smartfile)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartfile/master/dependencies/npm)
|
||||||
### Usage
|
[](https://www.bithound.io/github/pushrocks/smartfile)
|
||||||
This npm package comes with everything you need to start your own gulp plugin.
|
[](https://codecov.io/github/pushrocks/smartfile?branch=master)
|
||||||
|
|
||||||
Features:
|
|
||||||
|
|
||||||
* TypeScript: Code your plugin in TypeScript
|
|
||||||
* Use gulp to compile TypeScript without the global gulp CLI Tool.
|
|
||||||
* Use travis to deploy to npm
|
|
||||||
* Have a master branch for the latest dev version
|
|
||||||
* Have a release branch for the latest npm version
|
|
||||||
|
|
||||||
This package **doesn't require global gulp** (just local -> simply do npm install`) to compile TypeScript.
|
|
||||||
|
|
||||||
* to compile TypeScript do `npm test` (You should chain your own tests to this command later on)
|
|
||||||
* to setup release do `npm run setup`
|
|
||||||
* to release a patch do `npm run release`
|
|
||||||
|
|
||||||
We recommend using travis for npm releasing and test integration.
|
|
||||||
|
|
||||||
#### The structure
|
|
||||||
|
|
||||||
```
|
|
||||||
gulp-bootstrap/
|
|
||||||
|
|
|
||||||
|- ts/
|
|
||||||
| |- compile/
|
|
||||||
| | |- compile.js **** contains gulp task`
|
|
||||||
| |- index.ts **** Your main TypeScript file.
|
|
||||||
|
|
|
||||||
|- index.js **** the compiled module
|
|
||||||
```
|
|
||||||
|
|
||||||
|
## Supported file types:
|
||||||
|
* .yml .yaml
|
||||||
|
* .json
|
||||||
|
17
dist/index.d.ts
vendored
Normal file
17
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import * as SmartfileChecks from "./smartfile.checks";
|
||||||
|
import * as SmartfileFsaction from "./smartfile.fsaction";
|
||||||
|
import * as SmartfileGet from "./smartfile.get";
|
||||||
|
import * as SmartfileLocal from "./smartfile.local";
|
||||||
|
import * as SmartfileMemory from "./smartfile.memory";
|
||||||
|
import * as SmartfileRemote from "./smartfile.remote";
|
||||||
|
declare var smartfile: {
|
||||||
|
fsaction: typeof SmartfileFsaction;
|
||||||
|
fs: any;
|
||||||
|
checks: typeof SmartfileChecks;
|
||||||
|
get: typeof SmartfileGet;
|
||||||
|
local: typeof SmartfileLocal;
|
||||||
|
memory: typeof SmartfileMemory;
|
||||||
|
remote: typeof SmartfileRemote;
|
||||||
|
requireReload: (path: string) => any;
|
||||||
|
};
|
||||||
|
export = smartfile;
|
22
dist/index.js
vendored
Normal file
22
dist/index.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
var SmartfileChecks = require("./smartfile.checks");
|
||||||
|
var SmartfileFsaction = require("./smartfile.fsaction");
|
||||||
|
var SmartfileGet = require("./smartfile.get");
|
||||||
|
var SmartfileLocal = require("./smartfile.local");
|
||||||
|
var SmartfileMemory = require("./smartfile.memory");
|
||||||
|
var SmartfileRemote = require("./smartfile.remote");
|
||||||
|
var smartfile = {
|
||||||
|
fsaction: SmartfileFsaction,
|
||||||
|
fs: plugins.fs,
|
||||||
|
checks: SmartfileChecks,
|
||||||
|
get: SmartfileGet,
|
||||||
|
local: SmartfileLocal,
|
||||||
|
memory: SmartfileMemory,
|
||||||
|
remote: SmartfileRemote,
|
||||||
|
requireReload: SmartfileLocal.requireReload
|
||||||
|
};
|
||||||
|
module.exports = smartfile;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFFNUMsSUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQU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cIjtcbmltcG9ydCAqIGFzIFNtYXJ0ZmlsZUxvY2FsIGZyb20gXCIuL3NtYXJ0ZmlsZS5sb2NhbFwiO1xuaW1wb3J0ICogYXMgU21hcnRmaWxlTWVtb3J5IGZyb20gXCIuL3NtYXJ0ZmlsZS5tZW1vcnlcIjtcbmltcG9ydCAqIGFzIFNtYXJ0ZmlsZVJlbW90ZSBmcm9tIFwiLi9zbWFydGZpbGUucmVtb3RlXCI7XG5cblxudmFyIHNtYXJ0ZmlsZSA9IHtcbiAgICBmc2FjdGlvbjogU21hcnRmaWxlRnNhY3Rpb24sXG4gICAgZnM6IHBsdWdpbnMuZnMsXG4gICAgY2hlY2tzOiBTbWFydGZpbGVDaGVja3MsXG4gICAgZ2V0OiBTbWFydGZpbGVHZXQsXG4gICAgbG9jYWw6IFNtYXJ0ZmlsZUxvY2FsLFxuICAgIG1lbW9yeTogU21hcnRmaWxlTWVtb3J5LFxuICAgIHJlbW90ZTogU21hcnRmaWxlUmVtb3RlLFxuICAgIHJlcXVpcmVSZWxvYWQ6IFNtYXJ0ZmlsZUxvY2FsLnJlcXVpcmVSZWxvYWRcbn07XG5cbmV4cG9ydCA9IHNtYXJ0ZmlsZTtcbiJdfQ==
|
14
dist/smartfile.checks.d.ts
vendored
Normal file
14
dist/smartfile.checks.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export declare let fileExistsSync: (filePath: any) => boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export declare let fileExists: (filePath: any) => any;
|
||||||
|
export declare let isDirectory: (pathArg: any) => boolean;
|
||||||
|
export declare let isFile: (pathArg: any) => boolean;
|
39
dist/smartfile.checks.js
vendored
Normal file
39
dist/smartfile.checks.js
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
exports.fileExistsSync = function (filePath) {
|
||||||
|
var fileExistsBool = false;
|
||||||
|
try {
|
||||||
|
plugins.fs.readFileSync(filePath);
|
||||||
|
fileExistsBool = true;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
fileExistsBool = false;
|
||||||
|
}
|
||||||
|
return fileExistsBool;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
exports.fileExists = function (filePath) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
|
err ? done.reject() : done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.isDirectory = function (pathArg) {
|
||||||
|
return plugins.fs.statSync(pathArg).isDirectory();
|
||||||
|
};
|
||||||
|
exports.isFile = function (pathArg) {
|
||||||
|
return plugins.fs.statSync(pathArg).isFile();
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5jaGVja3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBRWhEOzs7O0dBSUc7QUFDUSxzQkFBYyxHQUFHLFVBQVMsUUFBUTtJQUN6QyxJQUFJLGNBQWMsR0FBVyxLQUFLLENBQUM7SUFDbkMsSUFBSSxDQUFDO1FBQ0QsT0FBTyxDQUFDLEVBQUUsQ0FBQyxZQUFZLENBQUMsUUFBUSxDQU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S5pc0RpcmVjdG9yeSgpO1xufTtcblxuZXhwb3J0IGxldCBpc0ZpbGUgPSBmdW5jdGlvbihwYXRoQXJnKTpib29sZWFue1xuICAgIHJldHVybiBwbHVnaW5zLmZzLnN0YXRTeW5jKHBhdGhBcmcpLmlzRmlsZSgpO1xufTtcbiJdfQ==
|
4
dist/smartfile.fsaction.d.ts
vendored
Normal file
4
dist/smartfile.fsaction.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export declare let copy: (fromArg: string, toArg: string) => any;
|
||||||
|
export declare let copySync: (fromArg: string, toArg: string) => boolean;
|
||||||
|
export declare let remove: (pathArg: string) => any;
|
||||||
|
export declare let removeSync: (pathArg: string) => boolean;
|
27
dist/smartfile.fsaction.js
vendored
Normal file
27
dist/smartfile.fsaction.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
exports.copy = function (fromArg, toArg) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.copy(fromArg, toArg, {}, function () {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.copySync = function (fromArg, toArg) {
|
||||||
|
plugins.fs.copySync(fromArg, toArg);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
exports.remove = function (pathArg) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.remove(pathArg, function () {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.removeSync = function (pathArg) {
|
||||||
|
plugins.fs.removeSync(pathArg);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5mc2FjdGlvbi50cyJdLCJu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vbihwYXRoQXJnOnN0cmluZyk6Ym9vbGVhbntcbiAgICBwbHVnaW5zLmZzLnJlbW92ZVN5bmMocGF0aEFyZyk7XG4gICAgcmV0dXJuIHRydWU7XG59OyJdfQ==
|
3
dist/smartfile.get.d.ts
vendored
Normal file
3
dist/smartfile.get.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export declare let filetype: (pathArg: string) => string;
|
||||||
|
export declare let foldersSync: (pathArg: any) => any;
|
||||||
|
export declare let folders: (pathArg: string) => any;
|
23
dist/smartfile.get.js
vendored
Normal file
23
dist/smartfile.get.js
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
exports.filetype = function (pathArg) {
|
||||||
|
var extName = plugins.path.extname(pathArg);
|
||||||
|
var fileType = extName.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
|
||||||
|
return fileType;
|
||||||
|
};
|
||||||
|
exports.foldersSync = function (pathArg) {
|
||||||
|
return plugins.fs.readdirSync(pathArg).filter(function (file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
exports.folders = function (pathArg) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var folderArray = plugins.fs.readdirSync(pathArg).filter(function (file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
|
});
|
||||||
|
done.resolve(folderArray);
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5nZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxD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mVhZGRpclN5bmMocGF0aEFyZykuZmlsdGVyKGZ1bmN0aW9uKGZpbGUpIHtcbiAgICAgICAgcmV0dXJuIHBsdWdpbnMuZnMuc3RhdFN5bmMocGx1Z2lucy5wYXRoLmpvaW4ocGF0aEFyZywgZmlsZSkpLmlzRGlyZWN0b3J5KCk7XG4gICAgfSk7XG4gICAgZG9uZS5yZXNvbHZlKGZvbGRlckFycmF5KTtcbiAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xufTsiXX0=
|
2
dist/smartfile.interpreter.d.ts
vendored
Normal file
2
dist/smartfile.interpreter.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
declare var _default: (fileStringArg: string, fileTypeArg: any) => any;
|
||||||
|
export = _default;
|
17
dist/smartfile.interpreter.js
vendored
Normal file
17
dist/smartfile.interpreter.js
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
module.exports = function (fileStringArg, fileTypeArg) {
|
||||||
|
switch (fileTypeArg) {
|
||||||
|
case "yml":
|
||||||
|
case "yaml":
|
||||||
|
return plugins.yaml.safeLoad(fileStringArg);
|
||||||
|
case "json":
|
||||||
|
return JSON.parse(fileStringArg);
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("file type " + fileTypeArg.blue + " not supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5pbnRlcnByZXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw0Q0FBNEM7O0FBRTVDLElBQU8sT0FBTyxXQUFXLHFCQUFxQixDQUFDLENBQUM7QUFFaEQsaUJBQVMsVUFBUyxhQUFvQixFQUFFLFdBQVc7SUFDL0MsTUFBTSxDQU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VHlwZUFyZy5ibHVlICsgXCIgbm90IHN1cHBvcnRlZFwiKTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgIH1cbn0iXX0=
|
37
dist/smartfile.local.d.ts
vendored
Normal file
37
dist/smartfile.local.d.ts
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
export declare let toFS: (options: {
|
||||||
|
from: string;
|
||||||
|
toPath: string;
|
||||||
|
}, cb?: any) => void;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export declare let toGulpStreamSync: (filePathArg: string) => any;
|
||||||
|
export declare let toGulpDestSync: (folderPathArg: string) => any;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export declare let toObjectSync: (filePathArg: any, fileTypeArg?: any) => any;
|
||||||
|
/**
|
||||||
|
* reads a file content to a String
|
||||||
|
* @param filePath
|
||||||
|
* @returns {string|Buffer|any}
|
||||||
|
*/
|
||||||
|
export declare let toStringSync: (filePath: any) => any;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param options
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
export declare let toVinylSync: (filePathArg: any, options?: {}) => any;
|
||||||
|
/**
|
||||||
|
* lets you reload files hot.
|
||||||
|
* @param path
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export declare let requireReload: (path: string) => any;
|
62
dist/smartfile.local.js
vendored
Normal file
62
dist/smartfile.local.js
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
var SmartfileGet = require("./smartfile.get");
|
||||||
|
var SmartfileInterpreter = require("./smartfile.interpreter");
|
||||||
|
exports.toFS = function (options, cb) {
|
||||||
|
if (cb === void 0) { cb = undefined; }
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
exports.toGulpStreamSync = function (filePathArg) {
|
||||||
|
var stream = plugins.gulp.src(filePathArg);
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
exports.toGulpDestSync = function (folderPathArg) {
|
||||||
|
return plugins.gulp.dest(folderPathArg);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
exports.toObjectSync = function (filePathArg, fileTypeArg) {
|
||||||
|
var fileString = plugins.fs.readFileSync(filePathArg, 'utf8');
|
||||||
|
var fileType;
|
||||||
|
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileGet.filetype(filePathArg);
|
||||||
|
return SmartfileInterpreter(fileString, fileType);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* reads a file content to a String
|
||||||
|
* @param filePath
|
||||||
|
* @returns {string|Buffer|any}
|
||||||
|
*/
|
||||||
|
exports.toStringSync = function (filePath) {
|
||||||
|
var fileString;
|
||||||
|
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
||||||
|
return fileString;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param options
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
exports.toVinylSync = function (filePathArg, options) {
|
||||||
|
if (options === void 0) { options = {}; }
|
||||||
|
return plugins.vinylFile.readSync(filePathArg, options);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* lets you reload files hot.
|
||||||
|
* @param path
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
exports.requireReload = function (path) {
|
||||||
|
return plugins.requireReload(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json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lsZVBhdGhcbiAqIEByZXR1cm5zIHtzdHJpbmd8QnVmZmVyfGFueX1cbiAqL1xuZXhwb3J0IGxldCB0b1N0cmluZ1N5bmMgPSBmdW5jdGlvbihmaWxlUGF0aCkge1xuICAgIGxldCBmaWxlU3RyaW5nO1xuICAgIGZpbGVTdHJpbmcgPSBwbHVnaW5zLmZzLnJlYWRGaWxlU3luYyhmaWxlUGF0aCwgXCJ1dGY4XCIpO1xuICAgIHJldHVybiBmaWxlU3RyaW5nO1xufTtcblxuLyoqXG4gKlxuICogQHBhcmFtIGZpbGVQYXRoQXJnXG4gKiBAcGFyYW0gb3B0aW9uc1xuICogQHJldHVybnMge251bWJlcn1cbiAqL1xuZXhwb3J0IGxldCB0b1ZpbnlsU3luYyA9IGZ1bmN0aW9uKGZpbGVQYXRoQXJnLG9wdGlvbnMgPSB7fSkge1xuICAgIHJldHVybiBwbHVnaW5zLnZpbnlsRmlsZS5yZWFkU3luYyhmaWxlUGF0aEFyZyxvcHRpb25zKTtcbn07XG5cbi8qKlxuICogbGV0cyB5b3UgcmVsb2FkIGZpbGVzIGhvdC5cbiAqIEBwYXJhbSBwYXRoXG4gKiBAcmV0dXJucyB7YW55fVxuICovXG5leHBvcnQgbGV0IHJlcXVpcmVSZWxvYWQgPSBmdW5jdGlvbihwYXRoOnN0cmluZyl7XG4gICAgcmV0dXJuIHBsdWdpbnMucmVxdWlyZVJlbG9hZChwYXRoKTtcbn07Il19
|
54
dist/smartfile.memory.d.ts
vendored
Normal file
54
dist/smartfile.memory.d.ts
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
/**
|
||||||
|
* allows you to create a gulp stream
|
||||||
|
* from String, from an Array of Strings, from Vinyl File, from an Array of VinylFiles
|
||||||
|
* @param fileArg
|
||||||
|
* @returns stream.Readable
|
||||||
|
* @TODO: make it async;
|
||||||
|
*/
|
||||||
|
export declare let toGulpStream: (fileArg: string | string[] | plugins.vinyl | plugins.vinyl[], baseArg?: string) => any;
|
||||||
|
/**
|
||||||
|
* converts file to Object
|
||||||
|
* @param fileStringArg
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any|any}
|
||||||
|
*/
|
||||||
|
export declare let toObject: (fileStringArg: string, fileTypeArg: string) => any;
|
||||||
|
/**
|
||||||
|
* takes a string and converts it to vinyl file
|
||||||
|
* @param fileArg
|
||||||
|
* @param optionsArg
|
||||||
|
*/
|
||||||
|
export declare let toVinylFileSync: (fileArg: string, optionsArg?: {
|
||||||
|
filename?: string;
|
||||||
|
base?: string;
|
||||||
|
relPath?: string;
|
||||||
|
}) => plugins.vinyl;
|
||||||
|
/**
|
||||||
|
* takes a string array and some options and returns a vinylfile array
|
||||||
|
* @param arrayArg
|
||||||
|
* @param optionsArg
|
||||||
|
*/
|
||||||
|
export declare let toVinylArraySync: (arrayArg: string[], optionsArg?: {
|
||||||
|
filename?: string;
|
||||||
|
base?: string;
|
||||||
|
relPath?: string;
|
||||||
|
}) => any[];
|
||||||
|
/**
|
||||||
|
* takes a vinylFile object and converts it to String
|
||||||
|
*/
|
||||||
|
export declare let toStringSync: (fileArg: plugins.vinyl) => string;
|
||||||
|
/**
|
||||||
|
* writes string or vinyl file to disk.
|
||||||
|
* @param fileArg
|
||||||
|
* @param fileNameArg
|
||||||
|
* @param fileBaseArg
|
||||||
|
*/
|
||||||
|
export declare let toFs: (fileArg: any, optionsArg: {
|
||||||
|
fileName: string;
|
||||||
|
filePath: string;
|
||||||
|
}) => any;
|
||||||
|
export declare let toFsSync: (fileArg: any, optionsArg: {
|
||||||
|
fileName: string;
|
||||||
|
filePath: string;
|
||||||
|
}) => void;
|
128
dist/smartfile.memory.js
vendored
Normal file
128
dist/smartfile.memory.js
vendored
Normal file
File diff suppressed because one or more lines are too long
13
dist/smartfile.plugins.d.ts
vendored
Normal file
13
dist/smartfile.plugins.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export declare let beautylog: any;
|
||||||
|
export declare let fs: any;
|
||||||
|
export declare let gulp: any;
|
||||||
|
export declare let g: {
|
||||||
|
remoteSrc: any;
|
||||||
|
};
|
||||||
|
export import path = require("path");
|
||||||
|
export declare let q: any;
|
||||||
|
export import vinyl = require("vinyl");
|
||||||
|
export declare let vinylFile: any;
|
||||||
|
export declare let yaml: any;
|
||||||
|
export declare let request: any;
|
||||||
|
export declare let requireReload: any;
|
17
dist/smartfile.plugins.js
vendored
Normal file
17
dist/smartfile.plugins.js
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
exports.beautylog = require("beautylog");
|
||||||
|
exports.fs = require("fs-extra");
|
||||||
|
exports.gulp = require("gulp");
|
||||||
|
exports.g = {
|
||||||
|
remoteSrc: require("gulp-remote-src")
|
||||||
|
};
|
||||||
|
exports.path = require("path");
|
||||||
|
exports.q = require("q");
|
||||||
|
exports.vinyl = require("vinyl");
|
||||||
|
exports.vinylFile = require("vinyl-file");
|
||||||
|
exports.yaml = require("js-yaml");
|
||||||
|
exports.request = require("request");
|
||||||
|
exports.requireReload = require("require-reload");
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDakMsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDakMsVUFBRSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztBQUN6QixZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsR0FBRztJQUNYLFNBQVMsRUFBRSxPQUFPLENBQUMsaUJBQWlCLENBQUM7Q0FDeEMsQ0FBQztBQUNZLFlBQUksV0FBVyxNQUFNLENBQUMsQ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0IHJlcXVpcmVSZWxvYWQgPSByZXF1aXJlKFwicmVxdWlyZS1yZWxvYWRcIik7XG4iXX0=
|
19
dist/smartfile.remote.d.ts
vendored
Normal file
19
dist/smartfile.remote.d.ts
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
export declare let toFs: (from: string, toPath: string) => any;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export declare let toGulpStreamSync: (filePathArg: string, baseArg: string) => any;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fromArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export declare let toObject: (fromArg: string) => any;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fromArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export declare let toString: (fromArg: string) => any;
|
68
dist/smartfile.remote.js
vendored
Normal file
68
dist/smartfile.remote.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10
index.js
10
index.js
@ -1,10 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var through = require("through2");
|
|
||||||
var path = require("path");
|
|
||||||
module.exports = function (jadeTemplate, mojo) {
|
|
||||||
if (mojo === void 0) { mojo = undefined; }
|
|
||||||
return through.obj(function (file, enc, cb) {
|
|
||||||
//run callback function to signal end of plugin process.
|
|
||||||
return cb(null, file);
|
|
||||||
});
|
|
||||||
};
|
|
5
npmts.json
Normal file
5
npmts.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"mode":"default",
|
||||||
|
"codecov":true,
|
||||||
|
"coverageTreshold":80
|
||||||
|
}
|
25
package.json
25
package.json
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "smartfile",
|
"name": "smartfile",
|
||||||
"version": "0.0.1",
|
"version": "3.0.6",
|
||||||
"description": "offers smart ways to work with files in nodejs",
|
"description": "offers smart ways to work with files in nodejs",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd ts/compile && node compile.js)",
|
"test": "(npmts)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"reinstall": "(rm -r node_modules && npm install)",
|
||||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
||||||
"startdev": "(git checkout master && git pull origin master)"
|
"update": "(git checkout master && git pull origin master && npm install)",
|
||||||
|
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -24,10 +25,20 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartfile",
|
"homepage": "https://github.com/pushrocks/smartfile",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pushrocks": "^1.0.18"
|
"beautylog": "^4.1.2",
|
||||||
|
"fs-extra": "^0.30.0",
|
||||||
|
"gulp": "^3.9.1",
|
||||||
|
"gulp-remote-src": "^0.4.1",
|
||||||
|
"js-yaml": "^3.6.0",
|
||||||
|
"q": "^1.4.1",
|
||||||
|
"request": "^2.72.0",
|
||||||
|
"require-reload": "0.2.2",
|
||||||
|
"vinyl": "^1.1.1",
|
||||||
|
"vinyl-file": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "3.9.0",
|
"gulp-function": "^1.3.1",
|
||||||
"gulp-typescript": "2.9.2"
|
"npmts": "^5.1.5",
|
||||||
|
"should": "^8.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
test/mytest.json
Normal file
8
test/mytest.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"key1": "this works",
|
||||||
|
"key2": "this works too",
|
||||||
|
"key3": {
|
||||||
|
"nestedkey1": "hello"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
test/mytest.txt
Normal file
1
test/mytest.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Some TestString &&%$
|
4
test/mytest.yaml
Normal file
4
test/mytest.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
key1: this works
|
||||||
|
key2: this works too
|
||||||
|
key3:
|
||||||
|
nestedkey1: hello
|
0
test/test.d.ts
vendored
Normal file
0
test/test.d.ts
vendored
Normal file
188
test/test.js
Normal file
188
test/test.js
Normal file
File diff suppressed because one or more lines are too long
1
test/test.js.map
Normal file
1
test/test.js.map
Normal file
File diff suppressed because one or more lines are too long
206
test/test.ts
Normal file
206
test/test.ts
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
import * as smartfile from "../dist/index.js";
|
||||||
|
let beautylog = require("beautylog");
|
||||||
|
let gulp = require("gulp");
|
||||||
|
let gFunction = require("gulp-function");
|
||||||
|
import should = require("should");
|
||||||
|
let vinyl = require("vinyl");
|
||||||
|
|
||||||
|
describe("smartfile".yellow,function(){
|
||||||
|
describe(".checks".yellow,function(){
|
||||||
|
describe(".fileExistsSync".yellow,function(){
|
||||||
|
it("should return an accurate boolean",function(){
|
||||||
|
(smartfile.checks.fileExistsSync("./test/mytest.json")).should.be.true();
|
||||||
|
(smartfile.checks.fileExistsSync("./test/notthere.json")).should.be.false();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".fileExists".yellow,function(){
|
||||||
|
it("should return a working promise",function(){
|
||||||
|
(smartfile.checks.fileExists("./test/mytest.json")).should.be.Promise();
|
||||||
|
(smartfile.checks.fileExists("./test/mytest.json")).should.be.fulfilled();
|
||||||
|
(smartfile.checks.fileExists("./test/notthere.json")).should.not.be.fulfilled();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe(".fsaction".yellow,function(){
|
||||||
|
describe(".copy()".yellow,function(){
|
||||||
|
it("should copy a directory",function(){
|
||||||
|
smartfile.fsaction.copy("./test/testfolder/","./test/temp/")
|
||||||
|
});
|
||||||
|
it("should copy a file",function(){
|
||||||
|
smartfile.fsaction.copy("./test/mytest.yaml","./test/temp/")
|
||||||
|
});
|
||||||
|
it("should copy a file and rename it",function(){
|
||||||
|
smartfile.fsaction.copy("./test/mytest.yaml","./test/temp/mytestRenamed.yaml")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".remove()",function(){
|
||||||
|
it("should remove an entire directory",function(){
|
||||||
|
|
||||||
|
});
|
||||||
|
it("should remove single files",function(){
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(".get",function(){
|
||||||
|
describe(".filetype()",function(){
|
||||||
|
it("should get the file type from a string",function(){
|
||||||
|
smartfile.get.filetype("./somefolder/data.json").should.equal("json");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".foldersSync()",function(){
|
||||||
|
it("should get the file type from a string",function(){
|
||||||
|
smartfile.get.foldersSync("./test/").should.containDeep([ "testfolder"]);
|
||||||
|
smartfile.get.foldersSync("./test/").should.not.containDeep([ "notExistentFolder"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".folders()",function(){
|
||||||
|
it("should get the file type from a string",function(done){
|
||||||
|
smartfile.get.folders("./test/")
|
||||||
|
.then(function(folderArrayArg){
|
||||||
|
folderArrayArg.should.containDeep([ "testfolder"]);
|
||||||
|
folderArrayArg.should.not.containDeep([ "notExistentFolder"]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe(".local".yellow,function(){
|
||||||
|
describe("toGulpStreamSync() and toGulpDestSync",function(){
|
||||||
|
it("should produce a gulp stream",function(done){
|
||||||
|
smartfile.local.toGulpStreamSync("./test/my*")
|
||||||
|
.pipe(smartfile.local.toGulpDestSync("./test/temp/"))
|
||||||
|
.pipe(gFunction(done,"atEnd"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".toObjectSync()".yellow,function(){
|
||||||
|
it("should read an " + ".yaml".blue + " file to an object",function(){
|
||||||
|
let testData = smartfile.local.toObjectSync("./test/mytest.yaml");
|
||||||
|
testData.should.have.property("key1","this works");
|
||||||
|
testData.should.have.property("key2","this works too");
|
||||||
|
|
||||||
|
});
|
||||||
|
it("should state unknown file type for unknown file types",function(){
|
||||||
|
let testData = smartfile.local.toObjectSync("./test/mytest.txt");
|
||||||
|
});
|
||||||
|
it("should read an " + ".json".blue + " file to an object",function(){
|
||||||
|
let testData = smartfile.local.toObjectSync("./test/mytest.json");
|
||||||
|
testData.should.have.property("key1","this works");
|
||||||
|
testData.should.have.property("key2","this works too");
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".toStringSync()".yellow,function(){
|
||||||
|
it("should read a file to a string",function(){
|
||||||
|
should.equal(
|
||||||
|
smartfile.local.toStringSync("./test/mytest.txt"),
|
||||||
|
"Some TestString &&%$"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".toVinylSync".yellow,function(){
|
||||||
|
it("should read an " + ".json OR .yaml".blue + " file to an " + "vinyl file object".cyan,function(){
|
||||||
|
let testData = smartfile.local.toVinylSync("./test/mytest.json");
|
||||||
|
(vinyl.isVinyl(testData)).should.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)
|
||||||
|
.pipe(gulp.dest("./test/temp/"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("toVinylFileSync()",function(){
|
||||||
|
it("should produce a vinylFile",function(){
|
||||||
|
let localString = "myString";
|
||||||
|
let localOptions = {filename:"vinylfile2",base:"/someDir"};
|
||||||
|
(smartfile.memory.toVinylFileSync(localString,localOptions) instanceof vinyl).should.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);
|
||||||
|
testResult.should.be.Array();
|
||||||
|
(testResult.length === 3).should.be.true();
|
||||||
|
for (let myKey in testResult){
|
||||||
|
(testResult[myKey] instanceof vinyl).should.be.true();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("toStringSync()",function(){
|
||||||
|
it("should produce a String from vinyl file",function(){
|
||||||
|
let localString = smartfile.memory.toStringSync(new vinyl({
|
||||||
|
base:"/",
|
||||||
|
path:"/test.txt",
|
||||||
|
contents: new Buffer("myString")
|
||||||
|
}));
|
||||||
|
localString.should.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,
|
||||||
|
{
|
||||||
|
fileName:"./test/temp/testMemToFs.txt",
|
||||||
|
filePath:process.cwd()
|
||||||
|
}
|
||||||
|
).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,{
|
||||||
|
fileName:"./test/temp/testMemToFsSync.txt",
|
||||||
|
filePath:process.cwd()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(".remote",function(){
|
||||||
|
describe("toGulpStreamSync()",function(){
|
||||||
|
it("should produce a gulp stream",function(done){
|
||||||
|
smartfile.remote.toGulpStreamSync("mytest.txt","https://raw.githubusercontent.com/pushrocks/smartfile/master/test/")
|
||||||
|
.pipe(smartfile.local.toGulpDestSync("./test/temp/"))
|
||||||
|
.pipe(gFunction(done,"atEnd"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
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){
|
||||||
|
should.equal(responseString,"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();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
0
test/testfolder/testfile1.txt
Normal file
0
test/testfolder/testfile1.txt
Normal file
0
test/testfolder/testfile2.txt
Normal file
0
test/testfolder/testfile2.txt
Normal file
@ -1,21 +0,0 @@
|
|||||||
// import gulp
|
|
||||||
var gulp = require("gulp")
|
|
||||||
var gulpTypescript = require("gulp-typescript");
|
|
||||||
var pr = require("pushrocks");
|
|
||||||
|
|
||||||
gulp.task('compileTS', function() {
|
|
||||||
var stream = gulp.src('../index.ts')
|
|
||||||
.pipe(gulpTypescript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest("../../"));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('default',['compileTS'], function() {
|
|
||||||
pr.beautylog.success('Typescript compiled');
|
|
||||||
});
|
|
||||||
|
|
||||||
//lets tell gulp to start with the default task.
|
|
||||||
pr.beautylog.log('Starting Gulp to compile TypeScript');
|
|
||||||
gulp.start.apply(gulp, ['default']);
|
|
@ -1,2 +0,0 @@
|
|||||||
# How to compile.
|
|
||||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
|
29
ts/index.ts
29
ts/index.ts
@ -1,12 +1,23 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var through = require("through2");
|
|
||||||
var path = require("path");
|
|
||||||
|
|
||||||
module.exports = (jadeTemplate,mojo = undefined) => {
|
import * as plugins from "./smartfile.plugins";
|
||||||
|
import * as SmartfileChecks from "./smartfile.checks";
|
||||||
|
import * as SmartfileFsaction from "./smartfile.fsaction";
|
||||||
|
import * as SmartfileGet from "./smartfile.get";
|
||||||
|
import * as SmartfileLocal from "./smartfile.local";
|
||||||
|
import * as SmartfileMemory from "./smartfile.memory";
|
||||||
|
import * as SmartfileRemote from "./smartfile.remote";
|
||||||
|
|
||||||
return through.obj((file, enc, cb) => {
|
|
||||||
|
var smartfile = {
|
||||||
//run callback function to signal end of plugin process.
|
fsaction: SmartfileFsaction,
|
||||||
return cb(null, file);
|
fs: plugins.fs,
|
||||||
});
|
checks: SmartfileChecks,
|
||||||
|
get: SmartfileGet,
|
||||||
|
local: SmartfileLocal,
|
||||||
|
memory: SmartfileMemory,
|
||||||
|
remote: SmartfileRemote,
|
||||||
|
requireReload: SmartfileLocal.requireReload
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export = smartfile;
|
||||||
|
40
ts/smartfile.checks.ts
Normal file
40
ts/smartfile.checks.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export let fileExistsSync = function(filePath):boolean {
|
||||||
|
let fileExistsBool:boolean = false;
|
||||||
|
try {
|
||||||
|
plugins.fs.readFileSync(filePath);
|
||||||
|
fileExistsBool = true
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
fileExistsBool = false;
|
||||||
|
}
|
||||||
|
return fileExistsBool;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let fileExists = function(filePath){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
|
err ? done.reject() : done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let isDirectory = function(pathArg):boolean{
|
||||||
|
return plugins.fs.statSync(pathArg).isDirectory();
|
||||||
|
};
|
||||||
|
|
||||||
|
export let isFile = function(pathArg):boolean{
|
||||||
|
return plugins.fs.statSync(pathArg).isFile();
|
||||||
|
};
|
30
ts/smartfile.fsaction.ts
Normal file
30
ts/smartfile.fsaction.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
import SmartfileChecks = require("./smartfile.checks");
|
||||||
|
|
||||||
|
export let copy = function(fromArg:string, toArg:string){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.copy(fromArg,toArg,{},function(){
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let copySync = function(fromArg:string,toArg:string):boolean{
|
||||||
|
plugins.fs.copySync(fromArg,toArg);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let remove = function(pathArg:string){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.remove(pathArg,function(){
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let removeSync = function(pathArg:string):boolean{
|
||||||
|
plugins.fs.removeSync(pathArg);
|
||||||
|
return true;
|
||||||
|
};
|
23
ts/smartfile.get.ts
Normal file
23
ts/smartfile.get.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
|
||||||
|
export let filetype = function(pathArg:string):string {
|
||||||
|
let extName = plugins.path.extname(pathArg);
|
||||||
|
let fileType = extName.replace(/\.([a-z]*)/,"$1"); //remove . form fileType
|
||||||
|
return fileType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let foldersSync = function(pathArg){
|
||||||
|
return plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export let folders = function(pathArg:string){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
let folderArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
|
});
|
||||||
|
done.resolve(folderArray);
|
||||||
|
return done.promise;
|
||||||
|
};
|
16
ts/smartfile.interpreter.ts
Normal file
16
ts/smartfile.interpreter.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
|
||||||
|
export = function(fileStringArg:string, fileTypeArg){
|
||||||
|
switch (fileTypeArg) {
|
||||||
|
case "yml" :
|
||||||
|
case "yaml":
|
||||||
|
return plugins.yaml.safeLoad(fileStringArg);
|
||||||
|
case "json":
|
||||||
|
return JSON.parse(fileStringArg);
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("file type " + fileTypeArg.blue + " not supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
65
ts/smartfile.local.ts
Normal file
65
ts/smartfile.local.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
import SmartfileGet = require("./smartfile.get");
|
||||||
|
import SmartfileInterpreter = require("./smartfile.interpreter");
|
||||||
|
export let toFS = function(options:{from:string,toPath:string}, cb=undefined){
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export let toGulpStreamSync = function(filePathArg:string){
|
||||||
|
let stream = plugins.gulp.src(filePathArg);
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let toGulpDestSync = function(folderPathArg:string){
|
||||||
|
return plugins.gulp.dest(folderPathArg);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let toObjectSync = function(filePathArg,fileTypeArg?) {
|
||||||
|
let fileString = plugins.fs.readFileSync(filePathArg, 'utf8');
|
||||||
|
let fileType;
|
||||||
|
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileGet.filetype(filePathArg);
|
||||||
|
return SmartfileInterpreter(fileString,fileType);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reads a file content to a String
|
||||||
|
* @param filePath
|
||||||
|
* @returns {string|Buffer|any}
|
||||||
|
*/
|
||||||
|
export let toStringSync = function(filePath) {
|
||||||
|
let fileString;
|
||||||
|
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
||||||
|
return fileString;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param options
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
export let toVinylSync = function(filePathArg,options = {}) {
|
||||||
|
return plugins.vinylFile.readSync(filePathArg,options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lets you reload files hot.
|
||||||
|
* @param path
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let requireReload = function(path:string){
|
||||||
|
return plugins.requireReload(path);
|
||||||
|
};
|
134
ts/smartfile.memory.ts
Normal file
134
ts/smartfile.memory.ts
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
import SmartfileInterpreter = require("./smartfile.interpreter");
|
||||||
|
let Readable = require("stream").Readable;
|
||||||
|
/**
|
||||||
|
* allows you to create a gulp stream
|
||||||
|
* from String, from an Array of Strings, from Vinyl File, from an Array of VinylFiles
|
||||||
|
* @param fileArg
|
||||||
|
* @returns stream.Readable
|
||||||
|
* @TODO: make it async;
|
||||||
|
*/
|
||||||
|
export let toGulpStream = function(fileArg:string|string[]|plugins.vinyl|plugins.vinyl[],baseArg:string = "/"){
|
||||||
|
let fileArray = [];
|
||||||
|
|
||||||
|
if(typeof fileArg === "string" || fileArg instanceof plugins.vinyl){ // make sure we work with an array later on
|
||||||
|
fileArray.push(fileArg);
|
||||||
|
} else if (Array.isArray(fileArg)){
|
||||||
|
fileArray = fileArg;
|
||||||
|
} else {
|
||||||
|
throw new Error("fileArg has unknown format");
|
||||||
|
}
|
||||||
|
|
||||||
|
let vinylFileArray:plugins.vinyl[] = []; //we want to have an array of vinylFiles
|
||||||
|
|
||||||
|
for (let fileIndexArg in fileArray){ //convert fileArray in vinylArray
|
||||||
|
let file = fileArray[fileIndexArg];
|
||||||
|
file instanceof plugins.vinyl ?
|
||||||
|
vinylFileArray.push(file) :
|
||||||
|
vinylFileArray.push(toVinylFileSync(file,{filename:fileIndexArg,base:baseArg}));
|
||||||
|
};
|
||||||
|
|
||||||
|
let stream = new Readable({ objectMode: true });
|
||||||
|
for(let vinylFileIndexArg in vinylFileArray){
|
||||||
|
let vinylFile = vinylFileArray[vinylFileIndexArg];
|
||||||
|
stream.push(vinylFile);
|
||||||
|
};
|
||||||
|
stream.push(null); //signal end of stream;
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* converts file to Object
|
||||||
|
* @param fileStringArg
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any|any}
|
||||||
|
*/
|
||||||
|
export let toObject = function(fileStringArg:string,fileTypeArg:string){
|
||||||
|
return SmartfileInterpreter(fileStringArg,fileTypeArg);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* takes a string and converts it to vinyl file
|
||||||
|
* @param fileArg
|
||||||
|
* @param optionsArg
|
||||||
|
*/
|
||||||
|
export let toVinylFileSync = function(fileArg:string,optionsArg?:{filename?:string,base?:string,relPath?:string}){
|
||||||
|
optionsArg? void(0) : optionsArg = {filename: "vinylfile", base: "/"};
|
||||||
|
optionsArg.filename ? void(0) : optionsArg.filename = "vinylfile";
|
||||||
|
optionsArg.base ? void(0) : optionsArg.base = "/";
|
||||||
|
optionsArg.relPath ? void("0") : optionsArg.relPath = "";
|
||||||
|
let vinylFile = new plugins.vinyl({
|
||||||
|
base: optionsArg.base,
|
||||||
|
path: plugins.path.join(optionsArg.base,optionsArg.relPath,optionsArg.filename),
|
||||||
|
contents: new Buffer(fileArg)
|
||||||
|
});
|
||||||
|
return vinylFile;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* takes a string array and some options and returns a vinylfile array
|
||||||
|
* @param arrayArg
|
||||||
|
* @param optionsArg
|
||||||
|
*/
|
||||||
|
export let toVinylArraySync = function(arrayArg:string[],optionsArg?:{filename?:string,base?:string,relPath?:string}){
|
||||||
|
let vinylArray = [];
|
||||||
|
for(let stringIndexArg in arrayArg){
|
||||||
|
let myString = arrayArg[stringIndexArg];
|
||||||
|
vinylArray.push(toVinylFileSync(myString,optionsArg));
|
||||||
|
}
|
||||||
|
return vinylArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* takes a vinylFile object and converts it to String
|
||||||
|
*/
|
||||||
|
export let toStringSync = function(fileArg:plugins.vinyl){
|
||||||
|
return fileArg.contents.toString("utf8");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* writes string or vinyl file to disk.
|
||||||
|
* @param fileArg
|
||||||
|
* @param fileNameArg
|
||||||
|
* @param fileBaseArg
|
||||||
|
*/
|
||||||
|
export let toFs = function(fileArg,optionsArg:{fileName:string,filePath:string}){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
|
||||||
|
//function checks to abort if needed
|
||||||
|
if (!fileArg || !optionsArg || !(typeof optionsArg.fileName === "string"))
|
||||||
|
throw new Error("expected a valid arguments");
|
||||||
|
if (!(typeof optionsArg.filePath === "string")) optionsArg.filePath = "/";
|
||||||
|
|
||||||
|
let filePath:string = plugins.path.join(optionsArg.filePath,optionsArg.fileName);
|
||||||
|
let fileString:string;
|
||||||
|
if (fileArg instanceof plugins.vinyl){
|
||||||
|
fileString = toStringSync(fileArg);
|
||||||
|
} else if (typeof fileArg === "string") {
|
||||||
|
fileString = fileArg;
|
||||||
|
}
|
||||||
|
plugins.fs.writeFile(filePath,fileString,"utf8",done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let toFsSync = function(fileArg,optionsArg:{fileName:string,filePath:string}){
|
||||||
|
//function checks to abort if needed
|
||||||
|
if (!fileArg || !optionsArg || !(typeof optionsArg.fileName === "string"))
|
||||||
|
throw new Error("expected a valid arguments");
|
||||||
|
if (!(typeof optionsArg.filePath === "string")) optionsArg.filePath = "/";
|
||||||
|
|
||||||
|
let filePath = plugins.path.join(optionsArg.filePath,optionsArg.fileName);
|
||||||
|
let fileString:string;
|
||||||
|
|
||||||
|
if (fileArg instanceof plugins.vinyl){
|
||||||
|
fileString = toStringSync(fileArg);
|
||||||
|
} else if (typeof fileArg === "string") {
|
||||||
|
fileString = fileArg;
|
||||||
|
}
|
||||||
|
plugins.fs.writeFileSync(filePath,fileString,"utf8");
|
||||||
|
};
|
||||||
|
|
14
ts/smartfile.plugins.ts
Normal file
14
ts/smartfile.plugins.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
export let beautylog = require("beautylog");
|
||||||
|
export let fs = require("fs-extra");
|
||||||
|
export let gulp = require("gulp");
|
||||||
|
export let g = {
|
||||||
|
remoteSrc: require("gulp-remote-src")
|
||||||
|
};
|
||||||
|
export import path = require("path");
|
||||||
|
export let q = require("q");
|
||||||
|
export import vinyl = require("vinyl");
|
||||||
|
export let vinylFile = require("vinyl-file");
|
||||||
|
export let yaml = require("js-yaml");
|
||||||
|
export let request = require("request");
|
||||||
|
export let requireReload = require("require-reload");
|
66
ts/smartfile.remote.ts
Normal file
66
ts/smartfile.remote.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
import SmartfileInterpreter = require("./smartfile.interpreter");
|
||||||
|
import SmartfileGet = require("./smartfile.get");
|
||||||
|
|
||||||
|
export let toFs = function(from:string,toPath:string) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
|
||||||
|
stream.on('finish',function(){
|
||||||
|
done.resolve(toPath);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export let toGulpStreamSync = function(filePathArg:string,baseArg:string){
|
||||||
|
let stream = plugins.g.remoteSrc(filePathArg, {
|
||||||
|
base: baseArg
|
||||||
|
});
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fromArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let toObject = function(fromArg:string){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||||
|
let returnObject;
|
||||||
|
if (!error && response.statusCode == 200) {
|
||||||
|
returnObject = SmartfileInterpreter(bodyString,SmartfileGet.filetype(fromArg));
|
||||||
|
done.resolve(returnObject);
|
||||||
|
} else {
|
||||||
|
console.log('could not get remote file from ' + fromArg);
|
||||||
|
returnObject = undefined;
|
||||||
|
done.reject(returnObject);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fromArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let toString = (fromArg:string) => {
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||||
|
if (!error && response.statusCode == 200) {
|
||||||
|
done.resolve(bodyString);
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.error('could not get remote file from ' + fromArg);
|
||||||
|
bodyString = undefined;
|
||||||
|
done.reject(bodyString);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
12
ts/tsd.json
12
ts/tsd.json
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
9
ts/typings.json
Normal file
9
ts/typings.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
|
||||||
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
|
"node": "registry:dt/node",
|
||||||
|
"should": "registry:dt/should",
|
||||||
|
"vinyl": "registry:dt/vinyl"
|
||||||
|
}
|
||||||
|
}
|
2079
ts/typings/node/node.d.ts
vendored
2079
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
1
ts/typings/tsd.d.ts
vendored
1
ts/typings/tsd.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
Reference in New Issue
Block a user