Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

template-file

Package Overview
Dependencies
Maintainers
10
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

template-file - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

dist/utils.d.ts

13

dist/cli.js

@@ -35,13 +35,7 @@ #!/usr/bin/env node

Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const glob_1 = __importDefault(require("glob"));
const meow_1 = __importDefault(require("meow"));
const p_limit_1 = __importDefault(require("p-limit"));
const path_1 = __importDefault(require("path"));
const util_1 = require("util");
const _1 = require(".");
function main() {
return __awaiter(this, void 0, void 0, function* () {
const glob = util_1.promisify(glob_1.default);
const limitOpenFiles = p_limit_1.default(64);
const cli = meow_1.default(`

@@ -68,8 +62,3 @@ Usage

const data = yield Promise.resolve().then(() => __importStar(require(path_1.default.resolve(dataFile))));
function renderToFile(file, destination) {
return limitOpenFiles(() => _1.renderTemplateFile(file, data).then(renderedString => fs_1.promises.writeFile(destination, renderedString)));
}
glob(sourceGlob)
.then(files => files.map(file => renderToFile(file, path_1.default.join(destination, path_1.default.basename(file)))))
.then(fileWriteOperations => Promise.all(fileWriteOperations));
_1.renderToFolder(sourceGlob, destination, data);
});

@@ -76,0 +65,0 @@ }

interface Data extends Record<string | number | symbol, string | number | Data | (() => string | number | Data)> {
}
export declare function renderGlob(sourceGlob: string, data: Data, onFileCallback: (filename: string, contents: string) => void): Promise<void>;
export declare function renderString(template: string, data: Data): string | Promise<string>;
export declare function renderTemplateFile(filepath: string, data: Data): Promise<string>;
export declare function renderToFolder(sourceGlob: string, destination: string, data: Data): Promise<void>;
export {};

@@ -11,6 +11,25 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderTemplateFile = exports.renderString = void 0;
exports.renderToFolder = exports.renderTemplateFile = exports.renderString = exports.renderGlob = void 0;
const deep_1 = require("@blakek/deep");
const fs_1 = require("fs");
const glob_1 = __importDefault(require("glob"));
const mkdirp_1 = __importDefault(require("mkdirp"));
const path_1 = __importDefault(require("path"));
const util_1 = require("util");
const utils_1 = require("./utils");
function renderGlob(sourceGlob, data, onFileCallback) {
return __awaiter(this, void 0, void 0, function* () {
const glob = util_1.promisify(glob_1.default);
const files = yield glob(sourceGlob);
for (const file of files) {
const contents = yield utils_1.limitOpenFiles(() => renderTemplateFile(file, data));
onFileCallback(file, contents);
}
});
}
exports.renderGlob = renderGlob;
function renderString(template, data) {

@@ -38,2 +57,13 @@ return template.replace(/\{\{\s*(.*?)\s*\}\}/g, (_match, captured) => {

exports.renderTemplateFile = renderTemplateFile;
function renderToFolder(sourceGlob, destination, data) {
return __awaiter(this, void 0, void 0, function* () {
yield mkdirp_1.default(destination);
function writeFile(filename, contents) {
const fullPath = path_1.default.join(destination, path_1.default.basename(filename));
fs_1.promises.writeFile(fullPath, contents);
}
return renderGlob(sourceGlob, data, writeFile);
});
}
exports.renderToFolder = renderToFolder;
//# sourceMappingURL=index.js.map
{
"name": "template-file",
"version": "4.0.2",
"version": "4.1.0",
"main": "dist/index.js",

@@ -42,3 +42,4 @@ "description": "🔀 Replace {{ variables }} in all your files",

"ts-node/register"
]
],
"timeout": "30s"
},

@@ -54,2 +55,3 @@ "browserslist": [

"meow": "^8.0.0",
"mkdirp": "^1.0.4",
"p-limit": "^3.1.0"

@@ -68,2 +70,3 @@ },

"@types/glob": "^7.1.3",
"@types/mkdirp": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^4.9.0",

@@ -70,0 +73,0 @@ "@typescript-eslint/parser": "^4.9.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc