Skip to content

Commit

Permalink
added post install scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Lau committed Apr 9, 2020
1 parent b5c4844 commit b82d167
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 9 deletions.
8 changes: 2 additions & 6 deletions generate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const fs = require('fs');
const Handlebars = require("handlebars");
const Helpers = require("./lib/Helpers");
const HandlebarsHelpers = require('./lib/HandlebarsHelpers');
const { TemplateSettings } = require('./lib/TemplateSettings');
const Template = require('./lib/Template');
const { TemplateLoader } = require("./lib/TemplateLoader");
const Generator = require('lb.generator.handlebars');

// This is a sample model object
const model = {
Expand Down Expand Up @@ -78,7 +74,7 @@ Template.prepareExportPath = function(settings, fileName, item) {

// Create a Template Loader and pass it the directory containing the templates.
// The loader will automatically load all template files ending in ".hbs" and their corresponding settings ".hbs.settings.json"
var loader = new TemplateLoader('./sample-templates');
var loader = new Generator.TemplateLoader('./sample-templates');

// Load the templates with a callback containing the list of loaded templates
loader.load(function (templates) {
Expand Down
15 changes: 15 additions & 0 deletions lb.generator.handlebars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Helpers = require("./lib/Helpers");
const HandlebarsHelpers = require("./lib/HandlebarsHelpers");
const Template = require("./lib/Template");
const { TemplateLoader } = require("./lib/TemplateLoader");
const { TemplateResult } = require("./lib/TemplateResult");
const { TemplateSettings } = require("./lib/TemplateSettings");

module.exports = {
HandlebarsHelpers,
Helpers,
Template,
TemplateLoader,
TemplateResult,
TemplateSettings
};
171 changes: 171 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "lb.generator.handlebars",
"version": "1.0.0",
"description": "Template code generator based on Handlebars",
"main": "generate.js",
"main": "lb.generator.handlebars.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node ./postinstall.js"
},
"repository": {
"type": "git",
Expand All @@ -22,6 +23,8 @@
},
"homepage": "https://github.com/dustylau/lb.generator.handlebars#readme",
"dependencies": {
"gently-copy": "^3.2.0",
"handlebars": "^4.7.6"
}
},
"devDependencies": {}
}
19 changes: 19 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// post-install.js

/**
* Script to run after npm install
*
* Copy selected files to user's directory
*/

'use strict';

var gentlyCopy = require('gently-copy');

var filesToCopy = ['generate.js', 'sample-templates'];

// User's local directory
var userPath = process.env.INIT_CWD;

// Moving files to user's local directory
gentlyCopy(filesToCopy, userPath);

0 comments on commit b82d167

Please sign in to comment.