Skip to content

Commit

Permalink
Merge pull request #65 from jaredwray/moving-to-helpers-folder-struct…
Browse files Browse the repository at this point in the history
…ure-for-legacy-and-src-for-typescript

moving to helpers folder structure for legacy and src for typescript
  • Loading branch information
jaredwray authored Oct 28, 2024
2 parents 47be57f + 1a7c50b commit 118b0e3
Show file tree
Hide file tree
Showing 52 changed files with 95 additions and 95 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"scripts": {
"test": "npm run build && c8 mocha --reporter list",
"test:ci": "npm run build && c8 --reporter=lcov mocha --reporter list",
"build": "rimraf ./dist && tsup ./index.ts --format cjs --dts --clean",
"build": "rimraf ./dist && tsup ./src/index.ts --format cjs --dts --clean",
"prepare": "npm run build",
"clean": "rimraf ./node_modules ./coverage yarn.lock package-lock.json ./dist ./dist-site",
"website:build": "rimraf ./site/readme.md && npx -y docula build -s ./site -o ./dist-site",
Expand Down
4 changes: 2 additions & 2 deletions index.ts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as HandlebarsLib from 'handlebars';
import helpersLib from './helpers.js';
import helpersLib from '../helpers/helpers.js';

/**
* Handlebars library not initiated with helpers
Expand All @@ -23,7 +23,7 @@ export const helpers = helpersLib;
*/
export async function createHandlebars() {
const handlebars = HandlebarsLib.create();
const helpersFunction = await import('./helpers.js');
const helpersFunction = await import('../helpers/helpers.js');
helpersFunction.default({ handlebars: handlebars });
return handlebars;
}
2 changes: 1 addition & 1 deletion test/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.array({handlebars: hbs});
helpers.string({handlebars: hbs});

Expand Down
2 changes: 1 addition & 1 deletion test/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.code({handlebars: hbs});

describe('code', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.array({handlebars: hbs});
helpers.collection({handlebars: hbs});
helpers.string({handlebars: hbs});
Expand Down
2 changes: 1 addition & 1 deletion test/comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.comparison({handlebars: hbs});

describe('comparison', function() {
Expand Down
134 changes: 67 additions & 67 deletions test/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ var fs = require('fs');
var path = require('path');
var assert = require('assert');
var hbs = require('handlebars').create();
require('../helpers')({handlebars: hbs});
require('../helpers/helpers.js')({handlebars: hbs});

var libFiles = fs.readdirSync(path.join(__dirname, '../lib'))
var libFiles = fs.readdirSync(path.join(__dirname, '../helpers/lib'))
.map(function(fp) {
return path.join('lib', fp);
return path.join('helpers/lib', fp);
});

describe('fs', function() {
Expand All @@ -23,16 +23,16 @@ describe('fs', function() {
describe('readdir', function() {
it('should return an array of files', function() {
var fn = hbs.compile('{{readdir dir}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), libFiles);
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), libFiles);
});

it('should work as a subexpression', function() {
var fn = hbs.compile('{{match (readdir dir) "**/[a-c]*.js"}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), [
'lib/array.js',
'lib/code.js',
'lib/collection.js',
'lib/comparison.js'
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), [
'helpers/lib/array.js',
'helpers/lib/code.js',
'helpers/lib/collection.js',
'helpers/lib/comparison.js'
]);
});

Expand All @@ -44,88 +44,88 @@ describe('fs', function() {
});
}

assert.deepEqual(fn({dir: 'lib', filter: filter}).split(','), [
path.join('lib', 'array.js'),
path.join('lib', 'code.js'),
path.join('lib', 'collection.js'),
path.join('lib', 'comparison.js'),
path.join('lib', 'date.js'),
path.join('lib', 'fs.js'),
path.join('lib', 'html.js'),
path.join('lib', 'i18n.js'),
path.join('lib', 'index.js'),
path.join('lib', 'inflection.js'),
path.join('lib', 'logging.js'),
path.join('lib', 'markdown.js'),
path.join('lib', 'match.js'),
path.join('lib', 'math.js'),
path.join('lib', 'md.js'),
path.join('lib', 'misc.js'),
path.join('lib', 'number.js'),
path.join('lib', 'object.js'),
path.join('lib', 'path.js'),
path.join('lib', 'regex.js'),
path.join('lib', 'string.js'),
path.join('lib', 'url.js')
assert.deepEqual(fn({dir: 'helpers/lib', filter: filter}).split(','), [
path.join('helpers/lib', 'array.js'),
path.join('helpers/lib', 'code.js'),
path.join('helpers/lib', 'collection.js'),
path.join('helpers/lib', 'comparison.js'),
path.join('helpers/lib', 'date.js'),
path.join('helpers/lib', 'fs.js'),
path.join('helpers/lib', 'html.js'),
path.join('helpers/lib', 'i18n.js'),
path.join('helpers/lib', 'index.js'),
path.join('helpers/lib', 'inflection.js'),
path.join('helpers/lib', 'logging.js'),
path.join('helpers/lib', 'markdown.js'),
path.join('helpers/lib', 'match.js'),
path.join('helpers/lib', 'math.js'),
path.join('helpers/lib', 'md.js'),
path.join('helpers/lib', 'misc.js'),
path.join('helpers/lib', 'number.js'),
path.join('helpers/lib', 'object.js'),
path.join('helpers/lib', 'path.js'),
path.join('helpers/lib', 'regex.js'),
path.join('helpers/lib', 'string.js'),
path.join('helpers/lib', 'url.js')
]);
});

it('should filter using a regex', function() {
var fn = hbs.compile('{{readdir dir (toRegex "\\.js$")}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), [
path.join('lib', 'array.js'),
path.join('lib', 'code.js'),
path.join('lib', 'collection.js'),
path.join('lib', 'comparison.js'),
path.join('lib', 'date.js'),
path.join('lib', 'fs.js'),
path.join('lib', 'html.js'),
path.join('lib', 'i18n.js'),
path.join('lib', 'index.js'),
path.join('lib', 'inflection.js'),
path.join('lib', 'logging.js'),
path.join('lib', 'markdown.js'),
path.join('lib', 'match.js'),
path.join('lib', 'math.js'),
path.join('lib', 'md.js'),
path.join('lib', 'misc.js'),
path.join('lib', 'number.js'),
path.join('lib', 'object.js'),
path.join('lib', 'path.js'),
path.join('lib', 'regex.js'),
path.join('lib', 'string.js'),
path.join('lib', 'url.js')
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), [
path.join('helpers/lib', 'array.js'),
path.join('helpers/lib', 'code.js'),
path.join('helpers/lib', 'collection.js'),
path.join('helpers/lib', 'comparison.js'),
path.join('helpers/lib', 'date.js'),
path.join('helpers/lib', 'fs.js'),
path.join('helpers/lib', 'html.js'),
path.join('helpers/lib', 'i18n.js'),
path.join('helpers/lib', 'index.js'),
path.join('helpers/lib', 'inflection.js'),
path.join('helpers/lib', 'logging.js'),
path.join('helpers/lib', 'markdown.js'),
path.join('helpers/lib', 'match.js'),
path.join('helpers/lib', 'math.js'),
path.join('helpers/lib', 'md.js'),
path.join('helpers/lib', 'misc.js'),
path.join('helpers/lib', 'number.js'),
path.join('helpers/lib', 'object.js'),
path.join('helpers/lib', 'path.js'),
path.join('helpers/lib', 'regex.js'),
path.join('helpers/lib', 'string.js'),
path.join('helpers/lib', 'url.js')
]);
});

it('should filter using a glob pattern', function() {
var fn = hbs.compile('{{readdir dir "lib/[a-d]*.js"}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), [
path.join('lib', 'array.js'),
path.join('lib', 'code.js'),
path.join('lib', 'collection.js'),
path.join('lib', 'comparison.js'),
path.join('lib', 'date.js')
var fn = hbs.compile('{{readdir dir "helpers/lib/[a-d]*.js"}}');
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), [
path.join('helpers/lib', 'array.js'),
path.join('helpers/lib', 'code.js'),
path.join('helpers/lib', 'collection.js'),
path.join('helpers/lib', 'comparison.js'),
path.join('helpers/lib', 'date.js')
]);
});

it('should filter by fs.stat (files)', function() {
var fn = hbs.compile('{{readdir dir "isFile"}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), libFiles.filter(function(fp) {
return fp.indexOf(path.join('lib', 'util')) !== 0;
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), libFiles.filter(function(fp) {
return fp.indexOf(path.join('helpers/lib', 'util')) !== 0;
}));
});

it('should filter by fs.stat (dirs)', function() {
var fn = hbs.compile('{{readdir dir "isDirectory"}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), [
path.join('lib', 'utils')
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), [
path.join('helpers/lib', 'utils')
]);
});

it('should return the whole array when the filter is invalid', function() {
var fn = hbs.compile('{{readdir dir "foo"}}');
assert.deepEqual(fn({dir: 'lib'}).split(','), libFiles);
assert.deepEqual(fn({dir: 'helpers/lib'}).split(','), libFiles);
});
});
});
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars');
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');

describe('helpers', function() {
it('should should return all helpers:', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.html({handlebars: hbs});

var locals = {data: [{aaa: 'AAA', bbb: 'BBB'}, {aaa: 'CCC', bbb: 'DDD'}]};
Expand Down
2 changes: 1 addition & 1 deletion test/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.i18n({handlebars: hbs});

var context = {language: 'en', en: {key: 'value', a: {b: 'c'}}, fr: {key: 'valeur'}};
Expand Down
2 changes: 1 addition & 1 deletion test/inflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.inflection({handlebars: hbs});

describe('inflection', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ require('mocha');
var assert = require('assert');
var fs = require('fs');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var markdownHelper = require('../lib/markdown.js');
var helpers = require('../helpers/helpers.js');
var markdownHelper = require('../helpers/lib/markdown.js');
helpers.markdown({handlebars: hbs});

describe('markdown', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var fs = require('fs');
var path = require('path');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.match({handlebars: hbs});

var testFiles = fs.readdirSync(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.math({handlebars: hbs});

describe('math', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/md.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var assert = require('assert');
var handlebars = require('handlebars');
var Templates = require('templates');
var hljs = require('highlight.js');
var md = require('../lib/md.js');
var md = require('../helpers/lib/md.js');
var _ = require('lodash');
var app;

Expand Down
2 changes: 1 addition & 1 deletion test/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');

describe('misc', function() {
beforeEach(function() {
Expand Down
2 changes: 1 addition & 1 deletion test/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.number({handlebars: hbs});

describe('number', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require('mocha');
var assert = require('assert');
var support = require('./support');
var expected = support.expected('object');
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
var hbs = require('handlebars').create();
helpers.math({handlebars: hbs});
helpers.object({handlebars: hbs});
Expand Down
2 changes: 1 addition & 1 deletion test/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var assert = require('assert');
var path = require('path');
var hbs = require('handlebars').create();
var gm = require('global-modules');
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.path({handlebars: hbs});

describe('assemble', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.regex({handlebars: hbs});

describe('regex', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.string({handlebars: hbs});

describe('string', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/subexpressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.array({handlebars: hbs});
helpers.string({handlebars: hbs});

Expand Down
2 changes: 1 addition & 1 deletion test/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('mocha');
var assert = require('assert');
var hbs = require('handlebars').create();
var helpers = require('../helpers.js');
var helpers = require('../helpers/helpers.js');
helpers.object({handlebars: hbs});
helpers.url({handlebars: hbs});

Expand Down
Loading

0 comments on commit 118b0e3

Please sign in to comment.