add webpack test
This commit is contained in:
@@ -12,3 +12,4 @@ npm-debug.log
|
|||||||
sauce_connect.log*
|
sauce_connect.log*
|
||||||
.idea
|
.idea
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
/handlebars-release.tgz
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd "$( dirname "$( readlink -f "$0" )" )" || exit 1
|
cd "$( dirname "$( readlink -f "$0" )" )" || exit 1
|
||||||
|
|
||||||
for i in */test.sh ; do
|
for i in */test.sh ; do
|
||||||
(
|
(
|
||||||
echo "----------------------------------------"
|
echo "----------------------------------------"
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "webpack-handlebars-loader-test",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"lockfileVersion": 1,
|
|
||||||
"requires": true,
|
|
||||||
"dependencies": {
|
|
||||||
"handlebars": {
|
|
||||||
"version": "file:../..",
|
|
||||||
"requires": {
|
|
||||||
"neo-async": "^2.6.0",
|
|
||||||
"optimist": "^0.6.1",
|
|
||||||
"source-map": "^0.6.1",
|
|
||||||
"uglify-js": "^3.1.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "webpack-handlebars-loader-test",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\""
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"handlebars": "file:../.."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
npm install
|
|
||||||
npm test
|
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
package-lock.json
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "webpack-test",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack --config webpack.config.js",
|
||||||
|
"test": "node dist/main.js"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"handlebars": "file:../..",
|
||||||
|
"handlebars-loader": "^1.7.1",
|
||||||
|
"webpack": "^4.39.3",
|
||||||
|
"webpack-cli": "^3.3.7"
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import Handlebars from 'handlebars/dist/handlebars';
|
||||||
|
|
||||||
|
import {assertEquals} from './lib/assert';
|
||||||
|
|
||||||
|
const template = Handlebars.compile('Author: {{author}}');
|
||||||
|
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import Handlebars from 'handlebars';
|
||||||
|
import {assertEquals} from './lib/assert';
|
||||||
|
|
||||||
|
|
||||||
|
const template = Handlebars.compile('Author: {{author}}');
|
||||||
|
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import {assertEquals} from './lib/assert';
|
||||||
|
|
||||||
|
import testTemplate from './test-template.handlebars';
|
||||||
|
assertEquals(testTemplate({author: 'Yehuda'}).trim(), 'Author: Yehuda');
|
||||||
|
|
||||||
|
|
||||||
|
const testTemplateRequire = require('./test-template.handlebars');
|
||||||
|
assertEquals(testTemplateRequire({author: 'Yehuda'}).trim(), 'Author: Yehuda');
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import * as Handlebars from 'handlebars/dist/handlebars';
|
||||||
|
|
||||||
|
import {assertEquals} from './lib/assert';
|
||||||
|
|
||||||
|
const template = Handlebars.compile('Author: {{author}}');
|
||||||
|
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import * as Handlebars from 'handlebars';
|
||||||
|
import {assertEquals} from './lib/assert';
|
||||||
|
|
||||||
|
const template = Handlebars.compile('Author: {{author}}');
|
||||||
|
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export function assertEquals(actual, expected) {
|
||||||
|
if (actual !== expected) {
|
||||||
|
throw new Error(`Expected "${actual}" to equal "${expected}"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Author: {{author}}
|
||||||
|
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Cleanup: package-lock and "npm ci" is not working with local dependencies
|
||||||
|
rm dist package-lock.json -rf
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
for i in dist/*-test.js ; do
|
||||||
|
echo "----------------------"
|
||||||
|
echo "-- Running $i"
|
||||||
|
echo "----------------------"
|
||||||
|
node "$i"
|
||||||
|
echo "Success"
|
||||||
|
done
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const testFiles = fs.readdirSync('src');
|
||||||
|
const entryPoints = {};
|
||||||
|
testFiles
|
||||||
|
.filter(file => file.match(/-test.js$/))
|
||||||
|
.forEach(file => {
|
||||||
|
entryPoints[file] = `./src/${file}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: entryPoints,
|
||||||
|
output: {
|
||||||
|
filename: '[name]',
|
||||||
|
path: __dirname + '/dist'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{test: /\.handlebars$/, loader: 'handlebars-loader'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "handlebars",
|
"name": "handlebars",
|
||||||
"version": "4.1.1",
|
"version": "4.1.2-0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user