add Smartfile.parsedPath

This commit is contained in:
Philipp Kunz 2017-05-07 23:00:56 +02:00
parent 5493d3cd5d
commit 30bc489822
5 changed files with 35 additions and 19 deletions

View File

@ -1,4 +1,5 @@
/// <reference types="node" /> /// <reference types="node" />
import * as plugins from './smartfile.plugins';
export interface ISmartfileConstructorOptions { export interface ISmartfileConstructorOptions {
path?: string; path?: string;
contentString?: string; contentString?: string;
@ -14,12 +15,17 @@ export declare class Smartfile {
* the full path of the file on disk * the full path of the file on disk
*/ */
path: string; path: string;
/**
*
*/
parsedPath: plugins.path.ParsedPath;
/** /**
* the content of the file as Buffer * the content of the file as Buffer
*/ */
contentBuffer: Buffer; contentBuffer: Buffer;
/** /**
* The current working directory of the file * The current working directory of the file
* Note:this is similar to gulp and different from native node path base
*/ */
base: string; base: string;
/** /**

View File

@ -29,6 +29,7 @@ class Smartfile {
console.log('created empty Smartfile?'); console.log('created empty Smartfile?');
} }
this.path = optionsArg.path; this.path = optionsArg.path;
this.parsedPath = plugins.path.parse(this.path);
this.base = optionsArg.base; this.base = optionsArg.base;
} }
/** /**
@ -105,4 +106,4 @@ class Smartfile {
} }
} }
exports.Smartfile = Smartfile; exports.Smartfile = Smartfile;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmNsYXNzZXMuc21hcnRmaWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBOEM7QUFTOUM7OztHQUdHO0FBQ0g7SUFxQkU7OztPQUdHO0lBQ0gsWUFBYSxVQUF3QztRQUNuRCxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQztZQUM3QixJQUFJLENBQUMsYUFBYSxHQUFHLFVBQVUsQ0FB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XO1FBQ3ZCLElBQUksQ0FBQyxhQUFhLEdBQUcsV0FBVyxDQUFBO0lBQ2xDLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUksR0FBRztRQUNMLE1BQU0sQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUE7SUFDdEIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsSUFBSSxRQUFRO1FBQ1YsTUFBTSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQ3BELENBQUM7SUFFRDs7T0FFRztJQUNILE1BQU07UUFDSixFQUFFLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO1lBQ3hCLE1BQU0sQ0FBQyxJQUFJLENBQUE7UUFDYixDQUFDO1FBQ0QsTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNkLENBQUM7SUFFRDs7T0FFRztJQUNILFFBQVE7UUFDTixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxZQUFZLE1BQU0sQ0FBQyxDQUFDLENBQUM7WUFDcEMsTUFBTSxDQUFDLElBQUksQ0FBQTtRQUNiLENBQUM7UUFDRCxNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUVELFdBQVc7UUFDVCxNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUVELFFBQVE7UUFDTixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUVELFVBQVU7UUFDUixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztDQUNGO0FBOUhELDhCQThIQyJ9

View File

@ -26,9 +26,9 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartfile", "homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": { "dependencies": {
"@types/fs-extra": "2.x.x", "@types/fs-extra": "3.x.x",
"@types/vinyl": "^2.0.0", "@types/vinyl": "^2.0.0",
"fs-extra": "^3.0.0", "fs-extra": "^3.0.1",
"glob": "^7.1.1", "glob": "^7.1.1",
"js-yaml": "^3.8.3", "js-yaml": "^3.8.3",
"require-reload": "0.2.2", "require-reload": "0.2.2",
@ -41,6 +41,6 @@
}, },
"devDependencies": { "devDependencies": {
"gulp-function": "^2.2.9", "gulp-function": "^2.2.9",
"tapbundle": "^1.0.10" "tapbundle": "^1.0.12"
} }
} }

View File

@ -17,6 +17,11 @@ export class Smartfile {
*/ */
path: string path: string
/**
*
*/
parsedPath: plugins.path.ParsedPath
/** /**
* the content of the file as Buffer * the content of the file as Buffer
*/ */
@ -24,6 +29,7 @@ export class Smartfile {
/** /**
* The current working directory of the file * The current working directory of the file
* Note:this is similar to gulp and different from native node path base
*/ */
base: string base: string
@ -36,6 +42,8 @@ export class Smartfile {
* the constructor of Smartfile * the constructor of Smartfile
* @param optionsArg * @param optionsArg
*/ */
constructor (optionsArg: ISmartfileConstructorOptions) { constructor (optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) { if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer this.contentBuffer = optionsArg.contentBuffer
@ -45,6 +53,7 @@ export class Smartfile {
console.log('created empty Smartfile?') console.log('created empty Smartfile?')
} }
this.path = optionsArg.path this.path = optionsArg.path
this.parsedPath = plugins.path.parse(this.path)
this.base = optionsArg.base this.base = optionsArg.base
} }

View File

@ -19,15 +19,15 @@
version "3.5.2" version "3.5.2"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.5.2.tgz#c11cd2817d3a401b7ba0f5a420f35c56139b1c1e" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.5.2.tgz#c11cd2817d3a401b7ba0f5a420f35c56139b1c1e"
"@types/fs-extra@2.x.x": "@types/fs-extra@3.x.x":
version "2.1.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-2.1.0.tgz#8b350239c0455d92b8d3c626edac193860ff395f" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-3.0.0.tgz#13e5566e4d780618ba52bd55e0dc713d7a687e59"
dependencies: dependencies:
"@types/node" "*" "@types/node" "*"
"@types/node@*": "@types/node@*":
version "7.0.14" version "7.0.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.14.tgz#1470fa002a113316ac9d9ad163fc738c7a0de2a4" resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.18.tgz#cd67f27d3dc0cfb746f0bdd5e086c4c5d55be173"
"@types/promises-a-plus@*": "@types/promises-a-plus@*":
version "0.0.27" version "0.0.27"
@ -74,7 +74,7 @@ bindings@^1.2.1:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11" resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11"
brace-expansion@^1.0.0: brace-expansion@^1.1.7:
version "1.1.7" version "1.1.7"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
dependencies: dependencies:
@ -159,9 +159,9 @@ first-chunk-stream@^2.0.0:
dependencies: dependencies:
readable-stream "^2.0.2" readable-stream "^2.0.2"
fs-extra@^3.0.0: fs-extra@^3.0.1:
version "3.0.0" version "3.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.0.tgz#244e0c4b0b8818f54040ec049d8a2bddc1202861" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291"
dependencies: dependencies:
graceful-fs "^4.1.2" graceful-fs "^4.1.2"
jsonfile "^3.0.0" jsonfile "^3.0.0"
@ -262,10 +262,10 @@ memwatch-next@^0.3.0:
nan "^2.3.2" nan "^2.3.2"
minimatch@^3.0.2: minimatch@^3.0.2:
version "3.0.3" version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies: dependencies:
brace-expansion "^1.0.0" brace-expansion "^1.1.7"
minimist@^1.2.0: minimist@^1.2.0:
version "1.2.0" version "1.2.0"
@ -420,9 +420,9 @@ strip-bom@^2.0.0:
dependencies: dependencies:
is-utf8 "^0.2.0" is-utf8 "^0.2.0"
tapbundle@^1.0.10: tapbundle@^1.0.12:
version "1.0.10" version "1.0.12"
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.0.10.tgz#36fd40036f6b5b738cbb9b5fc400df4c4031bc26" resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.0.12.tgz#71d29273aad280f5c4e15b2700430b2456a5d364"
dependencies: dependencies:
early "^2.1.1" early "^2.1.1"
leakage "^0.2.0" leakage "^0.2.0"