e3b049cefd
* run `docs` via npm * add shebang line to integrity.js, so npm will resolve node binary automatically * remove unnecessary build-jake npm script * add test.js script as replacement of Jakefile.js * remove Jakefile, remove jake from devDependencies * update docs * move scripts to separate directory * change shebang line from nodejs to js * change shebang line from js to node * update docs * use Karma cli instead of custom test script * add pretest and test-nolint scripts, remove lint scripts from travis.ci Run linting scripts in pretest script, this way test script will automatically trigger code linting. Add test-nolint script to have possibility to run tests without triggering pretest script with linting. This is useful when running tests in different browsers and tere's no sense to lint code more than one time * replace shebang lines with node executable in npm scripts * remove note about nodejs symlink in CONTRIBUTING.md
29 lines
1.3 KiB
JavaScript
Executable File
29 lines
1.3 KiB
JavaScript
Executable File
// This script calculates the integrity hashes of the files in dist/ , and
|
|
// **overwrites** the values in the documentation.
|
|
|
|
var ssri = require('ssri');
|
|
var fs = require('fs');
|
|
var version = require('../package.json').version;
|
|
|
|
const integritySrc = ssri.fromData(fs.readFileSync('dist/leaflet-src.js'));
|
|
const integrityUglified = ssri.fromData(fs.readFileSync('dist/leaflet.js'));
|
|
const integrityCss = ssri.fromData(fs.readFileSync('dist/leaflet.css'));
|
|
|
|
|
|
console.log('Integrity hashes for ', version, ':');
|
|
console.log('dist/leaflet-src.js: ', integritySrc.toString());
|
|
console.log('dist/leaflet.js: ', integrityUglified.toString());
|
|
console.log('dist/leaflet.css: ', integrityCss.toString());
|
|
|
|
var docConfig = fs.readFileSync('docs/_config.yml').toString();
|
|
|
|
docConfig = docConfig.
|
|
replace(/latest_leaflet_version:.*/, 'latest_leaflet_version: ' + version).
|
|
replace(/integrity_hash_source:.*/, 'integrity_hash_source: "' + integritySrc.toString() + '"').
|
|
replace(/integrity_hash_uglified:.*/, 'integrity_hash_uglified: "' + integrityUglified.toString() + '"').
|
|
replace(/integrity_hash_css:.*/, 'integrity_hash_css: "' + integrityCss.toString() + '"');
|
|
|
|
// console.log('New jekyll docs config: \n', docConfig);
|
|
|
|
fs.writeFileSync('docs/_config.yml', docConfig);
|