Fix build on Windows
Closes #1233 - Handle path-separators properly. Use "path.sep" instead of "/". Or use "require.resolve()" if possible - Use "execFile" instead of "exec" to run the Handlebars executable. This prevents problems due to (missing) shell escaping. - Use explicit call to "node" in order to run the executable on Windows. - Add "appveyor"-CI in order to run regular tests on Windows.
This commit is contained in:
committed by
Nils Knappmeier
parent
1ed163f4ae
commit
5b76f041b3
@@ -1,4 +1,5 @@
|
|||||||
[](https://travis-ci.org/wycats/handlebars.js)
|
[](https://travis-ci.org/wycats/handlebars.js)
|
||||||
|
[](https://ci.appveyor.com/project/wycats/handlebars-js)
|
||||||
[](https://saucelabs.com/u/handlebars)
|
[](https://saucelabs.com/u/handlebars)
|
||||||
|
|
||||||
Handlebars.js
|
Handlebars.js
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Test against these versions of Node.js
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- nodejs_version: "4"
|
||||||
|
- nodejs_version: "5"
|
||||||
|
|
||||||
|
platform:
|
||||||
|
- x64
|
||||||
|
|
||||||
|
# Install scripts (runs after repo cloning)
|
||||||
|
install:
|
||||||
|
# Get the latest stable version of Node.js
|
||||||
|
- ps: Install-Product node $env:nodejs_version $env:platform
|
||||||
|
# Clone submodules (mustache spec)
|
||||||
|
- cmd: git submodule update --init --recursive
|
||||||
|
# Install modules
|
||||||
|
- cmd: npm install
|
||||||
|
- cmd: npm install -g grunt-cli
|
||||||
|
|
||||||
|
|
||||||
|
# Post-install test scripts
|
||||||
|
test_script:
|
||||||
|
# Output useful info for debugging
|
||||||
|
- cmd: node --version
|
||||||
|
- cmd: npm --version
|
||||||
|
# Run tests
|
||||||
|
- cmd: grunt --stack travis
|
||||||
|
|
||||||
|
# Don't actually build
|
||||||
|
build: off
|
||||||
|
|
||||||
|
on_failure:
|
||||||
|
- cmd: 7z a coverage.zip coverage
|
||||||
|
- cmd: appveyor PushArtifact coverage.zip
|
||||||
|
|
||||||
|
|
||||||
|
# Set build version format here instead of in the admin panel
|
||||||
|
version: "{build}"
|
||||||
Vendored
+2
-1
@@ -9,7 +9,8 @@ var filename = 'dist/handlebars.js';
|
|||||||
if (global.minimizedTest) {
|
if (global.minimizedTest) {
|
||||||
filename = 'dist/handlebars.min.js';
|
filename = 'dist/handlebars.min.js';
|
||||||
}
|
}
|
||||||
vm.runInThisContext(fs.readFileSync(__dirname + '/../../' + filename), filename);
|
var distHandlebars = fs.readFileSync(require.resolve(`../../${filename}`), 'utf-8');
|
||||||
|
vm.runInThisContext(distHandlebars, filename);
|
||||||
|
|
||||||
global.CompilerContext = {
|
global.CompilerContext = {
|
||||||
browser: true,
|
browser: true,
|
||||||
|
|||||||
Vendored
+1
-1
@@ -15,7 +15,7 @@ if (grep === '--min') {
|
|||||||
|
|
||||||
var files = fs.readdirSync(testDir)
|
var files = fs.readdirSync(testDir)
|
||||||
.filter(function(name) { return (/.*\.js$/).test(name); })
|
.filter(function(name) { return (/.*\.js$/).test(name); })
|
||||||
.map(function(name) { return testDir + '/' + name; });
|
.map(function(name) { return testDir + path.sep + name; });
|
||||||
|
|
||||||
if (global.minimizedTest) {
|
if (global.minimizedTest) {
|
||||||
run('./runtime', function() {
|
run('./runtime', function() {
|
||||||
|
|||||||
+8
-2
@@ -6,9 +6,15 @@ module.exports = function(grunt) {
|
|||||||
grunt.registerTask('test:bin', function() {
|
grunt.registerTask('test:bin', function() {
|
||||||
var done = this.async();
|
var done = this.async();
|
||||||
|
|
||||||
|
var cmd = './bin/handlebars';
|
||||||
|
var args = [ '-a', 'spec/artifacts/empty.handlebars' ];
|
||||||
|
|
||||||
// On Windows, the executable handlebars.js file cannot be run directly
|
// On Windows, the executable handlebars.js file cannot be run directly
|
||||||
var prefix = os.type().match(/^Windows/) ? process.argv[0] : '';
|
if (os.platform() === 'win32') {
|
||||||
childProcess.exec(prefix + ' ./bin/handlebars -a spec/artifacts/empty.handlebars', function(err, stdout) {
|
args.unshift(cmd);
|
||||||
|
cmd = process.argv[0];
|
||||||
|
}
|
||||||
|
childProcess.execFile(cmd, args, function(err, stdout) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user