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

project-template

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

project-template

Generate a project based on a directory of template files and corresponding template values

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

project-template

npm version

Generate a project based on a directory of template files and corresponding template values.

Requirements

  • Node JS v6+

Install

yarn add project-template

Example

yarn run example

See example/index.js

Usage

const projectTemplate = require('project-template');

projectTemplate({
  templatePath: '/path/to/templates',
  buildPath: '/path/to/build',
  params: {
    'path/to/file.txt': {
      firstParam: 'First param value',
      secondParam: 'Second param value',
    },
    'path/to/different/file.txt': {
      anotherParam: 'Another param value',
    },
  },
})
.then(files => console.log('Done', files))
.catch(err => console.error('Error', err));

Things to keep in mind

  • Template files are expected to use ect syntax
  • Directory structure of files in templatePath is maintained in buildPath
  • All files in templatePath with fileExtension must be included in params
  • Files in templatePath without fileExtension are just copied over to buildPath
  • You cannot have two files with the same file path where one has fileExtension and the other doesn't

API

projectTemplate(options) -> Promise<Array<String>>

options
KeyTypeRequiredDefaultNotes
templatePathStringYesDirectory path containing template files
buildPathStringYesDirectory path to write generated files to
paramsObjectNo{}Keys are relative paths of template files (with fileExtension stripped). Values are objects of template variables
ignoreFilesArray<String>No[]File paths to ignore (exclude the fileExtension for template files). Useful for ect partials
fileExtensionStringNoectFile extension of template files
Result

The promise is resolved with an array of file paths of generated files, relative to the buildPath directory.

Keywords

FAQs

Package last updated on 09 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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