simplr-gulp
Version:
Fully functional gulpfile.js implementation. Tailored for Single Page Application. Written in TypeScript.
61 lines (60 loc) • 1.98 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
function WriteToFileAsJson(fileName, content) {
fs.writeFile(fileName, JSON.stringify(content, null, 4), (error) => {
console.error(error);
});
}
exports.WriteToFileAsJson = WriteToFileAsJson;
function Pad(num, size) {
var s = "000000000" + num.toString();
return s.substr(s.length - size);
}
exports.Pad = Pad;
function GetTimeNow() {
let date = new Date(), hours = Pad(date.getHours(), 2), minutes = Pad(date.getMinutes(), 2), seconds = Pad(date.getSeconds(), 2);
return `${hours}:${minutes}:${seconds}`;
}
exports.GetTimeNow = GetTimeNow;
function RemoveFullPath(directory) {
return directory.split(`${__dirname}\\`)[1];
}
exports.RemoveFullPath = RemoveFullPath;
function Ensure(...element) {
console.log(JSON.stringify(element));
}
exports.Ensure = Ensure;
function GetClassName(constructor) {
if (constructor != null) {
let functionString = constructor.toString();
if (functionString.length > 0) {
let match = functionString.match(/\w+/g);
if (match != null && match[1] != null) {
return match[1];
}
}
}
return "";
}
exports.GetClassName = GetClassName;
function ReplaceAll(content, regexSearch, replace) {
return content.replace(new RegExp(regexSearch), replace);
}
exports.ReplaceAll = ReplaceAll;
;
function FixSeparator(link) {
const correctSep = "/";
let wrongSeps = ["\\"];
if (path.sep !== correctSep && wrongSeps.indexOf(path.sep) === -1) {
wrongSeps.push(path.sep);
}
for (let i = 0; i < wrongSeps.length; i++) {
let wrongSep = wrongSeps[i];
while (link.indexOf(wrongSep) !== -1) {
link = link.replace(wrongSep, correctSep);
}
}
return link;
}
exports.FixSeparator = FixSeparator;