<commit_before>/*
 * Poly2Tri Copyright (c) 2009-2013, Poly2Tri Contributors
 * http://code.google.com/p/poly2tri/
 * 
 * poly2tri.js (JavaScript port) (c) 2009-2013, Poly2Tri Contributors
 * https://github.com/r3mi/poly2tri.js
 * 
 * Build script for poly2tri.js
 * <NAME>, 12/2013
 * 
 * All rights reserved.
 * 
 * Distributed under the 3-clause BSD License, see LICENSE.txt
 */

"use strict";

var browserify = require('browserify');
var fs = require('fs');
var uglify = require('uglify-js');
var pkg = require('./package.json');

// Update version file (require'd by main poly2tri.js for VERSION string)
fs.writeFileSync('./dist/version.json', '{"version": "' + pkg.version + '"}');

var today = new Date().toJSON().slice(0, 10);
var preamble = '/*! ' + pkg.name + ' v' + pkg.version + ' | built ' + today + ' | (c) 2009-2013 Poly2Tri Contributors */\n';

var b = browserify();
b.add('./src/poly2tri.js');
b.bundle({standalone: 'poly2tri'}, function(err, code) {
    fs.writeFileSync('./dist/poly2tri.js', code);

    var min = uglify.minify(code, {fromString: true, compress: true, mangle: true});
    fs.writeFileSync('./dist/poly2tri.min.js', preamble + min.code);
});<commit_msg>better error reporting during build<commit_after>/*
 * Poly2Tri Copyright (c) 2009-2013, Poly2Tri Contributors
 * http://code.google.com/p/poly2tri/
 * 
 * poly2tri.js (JavaScript port) (c) 2009-2013, Poly2Tri Contributors
 * https://github.com/r3mi/poly2tri.js
 * 
 * Build script for poly2tri.js
 * <NAME>, 12/2013
 * 
 * All rights reserved.
 * 
 * Distributed under the 3-clause BSD License, see LICENSE.txt
 */

"use strict";

var browserify = require('browserify');
var fs = require('fs');
var uglify = require('uglify-js');
var pkg = require('./package.json');

// Update version file (require'd by main poly2tri.js for VERSION string)
fs.writeFileSync('./dist/version.json', '{"version": "' + pkg.version + '"}');

var today = new Date().toJSON().slice(0, 10);
var preamble = '/*! ' + pkg.name + ' v' + pkg.version + ' | built ' + today + ' | (c) 2009-2013 Poly2Tri Contributors */\n';

var b = browserify();
b.add('./src/poly2tri.js');
b.bundle({standalone: 'poly2tri'}, function(err, code) {
    if (err instanceof Error) {
        throw(err);
    }
    if (err) {
        process.stderr.write(err);
    }
    if (code) {
        fs.writeFileSync('./dist/poly2tri.js', code);

        var min = uglify.minify(code, {fromString: true, compress: true, mangle: true});
        fs.writeFileSync('./dist/poly2tri.min.js', preamble + min.code);
    }
});
{'fraction_non_alphanumeric': 0.18303220738413198, 'fraction_numerical': 0.037706205813040065, 'mean_word_length': 3.605786618444846, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1604157', 'n_tokens_mistral': 952, 'n_tokens_neox': 866, 'n_words': 212}