Skip to content

Commit

Permalink
Replace js-yaml with yaml
Browse files Browse the repository at this point in the history
- js-yaml' development seems to be dead (no release for years, many open PRs and issues)
- yaml' is actively maintained and more modern (ESM)
  • Loading branch information
KristjanESPERANTO committed Jan 5, 2025
1 parent 5ea11a2 commit 2b93ce5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
23 changes: 21 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"globals": "^15.14.0",
"https": "^1.0.0",
"husky": "^9.1.7",
"js-yaml": "^4.1.0",
"line-reader": "^0.4.0",
"npm-check-updates": "^17.1.13",
"optimist": "^0.6.1",
Expand All @@ -84,7 +83,8 @@
"terser": "^5.37.0",
"timekeeper": "^2.3.1",
"typescript": "^5.7.2",
"typescript-eslint": "^8.19.0"
"typescript-eslint": "^8.19.0",
"yaml": "^2.7.0"
},
"engines": {
"node": ">=12"
Expand Down
4 changes: 2 additions & 2 deletions scripts/PH_SH_exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var opening_hours = require('../build/opening_hours.js');
var fs = require('fs');
var glob = require('glob');
var yaml = require('js-yaml');
var YAML = require('yaml');
/* }}} */

/* Parameter handling {{{ */
Expand Down Expand Up @@ -76,7 +76,7 @@ if (!(argv['public-holidays'] || argv['school-holidays'] || argv['all-locations'
let nominatim_by_loc = {};
for (let nominatim_file of glob.sync("src/holidays/nominatim_cache/*.yaml")) {
let country_state = nominatim_file.match(/^.*\/([^/]*)\.yaml$/)[1];
nominatim_by_loc[country_state] = yaml.load(fs.readFileSync(nominatim_file));
nominatim_by_loc[country_state] = YAML.parse(fs.readFileSync(nominatim_file, "utf8"));
}

/* }}} */
Expand Down
4 changes: 2 additions & 2 deletions scripts/yamlToJson.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import process from "node:process";
import { readFileSync, writeFileSync } from "node:fs";
import jsYaml from "js-yaml";
import { parse } from "yaml";

const [, , input, output] = process.argv;
const out = output || `${input.split(".")[0]}.json`;

console.log(`Converting ${input} to ${out}`);

const loadedYaml = jsYaml.load(readFileSync(input, { encoding: "utf-8" }));
const loadedYaml = parse(readFileSync(input, { encoding: "utf-8" }));
const jsonOutput = JSON.stringify(loadedYaml, null, 2);

writeFileSync(out, jsonOutput);
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var colors = require('colors');
var sprintf = require('sprintf-js').sprintf;
var timekeeper = require('timekeeper');
var glob = require('glob');
var yaml = require('js-yaml');
var YAML = require('yaml');
var fs = require('fs');
/* }}} */

Expand Down Expand Up @@ -97,7 +97,7 @@ var test = new opening_hours_test();
var nominatim_by_loc = {};
for (var nominatim_file of glob.sync("src/holidays/nominatim_cache/*.yaml")) {
var country_state = nominatim_file.match(/^.*\/([^/]*)\.yaml$/)[1];
nominatim_by_loc[country_state] = yaml.load(fs.readFileSync(nominatim_file));
nominatim_by_loc[country_state] = YAML.parse(fs.readFileSync(nominatim_file, "utf8"));
}

var nominatim_default = nominatim_by_loc.de_bw;
Expand Down

0 comments on commit 2b93ce5

Please sign in to comment.