update plugin to use nmpts
This commit is contained in:
parent
222bfb42cd
commit
48f44ee937
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,3 +1,8 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
.settings/
|
||||||
.idea/
|
.idea/
|
||||||
|
docs/
|
||||||
|
ts/typings/
|
||||||
|
ts/**/*.js
|
||||||
|
ts/**/*.js.map
|
||||||
|
coverage/
|
8
dist/index.js
vendored
Normal file
8
dist/index.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {{getPath: (function(any): undefined)}}
|
||||||
|
*/
|
||||||
|
var smartpath = {};
|
||||||
|
module.exports = smartpath;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBOzs7R0FHRztBQUNILElBQUksU0FBUyxHQUFHLEVBRWYsQ0FBQztBQUdGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsU0FBUyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cInR5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLnBsdWdpbnNcIik7XG5pbXBvcnQgU21hcnRwYXRoQWJzb2x1dGUgPSByZXF1aXJlKFwiLi9zbWFydHBhdGguYWJzb2x1dGVcIik7XG5cblxuLyoqXG4gKlxuICogQHR5cGUge3tnZXRQYXRoOiAoZnVuY3Rpb24oYW55KTogdW5kZWZpbmVkKX19XG4gKi9cbmxldCBzbWFydHBhdGggPSB7XG5cbn07XG5cblxubW9kdWxlLmV4cG9ydHMgPSBzbWFydHBhdGg7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
34
dist/smartpath.absolute.js
vendored
Normal file
34
dist/smartpath.absolute.js
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/// <reference path="typings/main.d.ts" />
|
||||||
|
var plugins = require("./smartpath.plugins");
|
||||||
|
var makeAbsolute = function (localPathArg, baseArg) {
|
||||||
|
var absolutePath;
|
||||||
|
if (baseArg) {
|
||||||
|
absolutePath = plugins.path.join(baseArg, localPathArg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
absolutePath = plugins.path.resolve(localPathArg);
|
||||||
|
}
|
||||||
|
return absolutePath;
|
||||||
|
};
|
||||||
|
var absolute = function (relativeArg, baseArg) {
|
||||||
|
if (typeof relativeArg === "string") {
|
||||||
|
return makeAbsolute(relativeArg);
|
||||||
|
}
|
||||||
|
else if (Array.isArray(relativeArg)) {
|
||||||
|
var relativeArray = relativeArg;
|
||||||
|
var absoluteArray;
|
||||||
|
for (var key in relativeArray) {
|
||||||
|
absoluteArray.push(makeAbsolute(relativeArray[key]));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return absoluteArray;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
|
||||||
|
"Input is neither String nor Array");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = absolute;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5hYnNvbHV0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7QUFDMUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVoRCxJQUFJLFlBQVksR0FBRyxVQUFTLFlBQW1CLEVBQUUsT0FBZTtJQUM1RCxJQUFJLFlBQW1CLENBQUM7SUFDeEIsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLENBQUEsQ0FBQztRQUNSLFlBQVks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gICAgICAgICBhYnNvbHV0ZUFycmF5LnB1c2gobWFrZUFic29sdXRlKHJlbGF0aXZlQXJyYXlba2V5XSkpO1xuICAgICAgICB9O1xuICAgICAgICByZXR1cm4gYWJzb2x1dGVBcnJheTtcbiAgICB9IGVsc2Uge1xuICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcInNtYXJ0cGF0aC5hYnNvbHV0ZSgpIGNvdWxkIG5vdCBtYWtlIHNlbnNlIG9mIHRoZSBpbnB1dC4gXCIgK1xuICAgICAgICAgICAgXCJJbnB1dCBpcyBuZWl0aGVyIFN0cmluZyBub3IgQXJyYXlcIik7XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG59O1xuXG5leHBvcnQgPSBhYnNvbHV0ZTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
5
dist/smartpath.plugins.js
vendored
Normal file
5
dist/smartpath.plugins.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
exports.beautylog = require("beautylog");
|
||||||
|
exports.path = require("path");
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUNqQyxpQkFBUyxHQUFHLE9BQU8sQ0FBRSxXQUFXLENBQUMsQ0FBQztBQUNsQyxZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0cGF0aC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuZXhwb3J0IHZhciBiZWF1dHlsb2cgPSByZXF1aXJlIChcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCB2YXIgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
@ -4,7 +4,7 @@
|
|||||||
"description": "offers smart ways to handle paths",
|
"description": "offers smart ways to handle paths",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "cd ts/compile && gulp"
|
"test": "(npmts)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -21,5 +21,10 @@
|
|||||||
"url": "https://github.com/pushrocks/smartpath/issues"
|
"url": "https://github.com/pushrocks/smartpath/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartpath",
|
"homepage": "https://github.com/pushrocks/smartpath",
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"beautylog": "^3.1.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"npmts": "^3.3.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
nvm use v0.12.7
|
|
||||||
gulp
|
|
@ -1,16 +0,0 @@
|
|||||||
// import gulp
|
|
||||||
var gulp = require("gulp"),
|
|
||||||
gulpTypescript = require("gulp-typescript");
|
|
||||||
|
|
||||||
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() {
|
|
||||||
console.log('Typescript compiled');
|
|
||||||
});
|
|
@ -1,2 +0,0 @@
|
|||||||
# How to compile.
|
|
||||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
|
17
ts/index.ts
17
ts/index.ts
@ -1,21 +1,14 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartpath.plugins");
|
||||||
|
import SmartpathAbsolute = require("./smartpath.absolute");
|
||||||
|
|
||||||
var path = require("path");
|
|
||||||
var bl = require("beautylog");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {{getPath: (function(any): undefined)}}
|
* @type {{getPath: (function(any): undefined)}}
|
||||||
*/
|
*/
|
||||||
var smartpath:any = {
|
let smartpath = {
|
||||||
getAbsPath: function(varPath,logBool = false) {
|
|
||||||
var absPath = path.resolve(varPath);
|
|
||||||
if (logBool == true) {
|
|
||||||
bl.log('varPath is' + varPath);
|
|
||||||
bl.log('absPath is' + absPath);
|
|
||||||
}
|
|
||||||
return absPath;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
31
ts/smartpath.absolute.ts
Normal file
31
ts/smartpath.absolute.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/// <reference path="typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartpath.plugins");
|
||||||
|
|
||||||
|
var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
||||||
|
let absolutePath:string;
|
||||||
|
if(baseArg){
|
||||||
|
absolutePath = plugins.path.join(baseArg,localPathArg);
|
||||||
|
} else {
|
||||||
|
absolutePath = plugins.path.resolve(localPathArg);
|
||||||
|
}
|
||||||
|
return absolutePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
var absolute = function(relativeArg:any, baseArg?:string):any {
|
||||||
|
if(typeof relativeArg === "string"){
|
||||||
|
return makeAbsolute(relativeArg);
|
||||||
|
} else if(Array.isArray(relativeArg)){
|
||||||
|
let relativeArray = relativeArg
|
||||||
|
let absoluteArray:string[];
|
||||||
|
for (let key in relativeArray){
|
||||||
|
absoluteArray.push(makeAbsolute(relativeArray[key]));
|
||||||
|
};
|
||||||
|
return absoluteArray;
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
|
||||||
|
"Input is neither String nor Array");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export = absolute;
|
3
ts/smartpath.plugins.ts
Normal file
3
ts/smartpath.plugins.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
export var beautylog = require ("beautylog");
|
||||||
|
export var path = require("path");
|
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
5
ts/typings.json
Normal file
5
ts/typings.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||||
|
}
|
||||||
|
}
|
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" />
|
|
Loading…
Reference in New Issue
Block a user