Skip to content

Commit

Permalink
Merge pull request #127 from phyloref/upgrade-to-es6
Browse files Browse the repository at this point in the history
This PR upgrades newick-js to v1.2.1, which requires some minor changes to how we call it. Newick-js v1.2.1 no longer works with Node.js v10.x, which makes sense -- it was EOL in April 2021. So this PR also removes that from the Node.js versions we test against.
  • Loading branch information
gaurav authored Aug 2, 2023
2 parents 6c111bc + c50dd3b commit ec8c86b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this library will be documented in this file.
The format is based on [Keep a Changelog] and this project adheres to [Semantic Versioning].

## [Unreleased]
- PR #127: Upgraded Newick.js to ^1.2.1. This means that we no longer
support Node.js v10.x, which end-of-lifed on April 30, 2021.

## [1.1.0] - 2023-05-11
- PR #129: Added curator notes to phylorefs and phylogenies.
Expand Down
80 changes: 40 additions & 40 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"jsonld": "^5.0.0",
"lodash": "^4.17.20",
"moment": "^2.27.0",
"newick-js": "1.1.1",
"newick-js": "^1.2.1",
"retus": "^1.1.1",
"yargs": "^15.4.1"
},
Expand Down
10 changes: 5 additions & 5 deletions src/wrappers/PhylogenyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const { has } = require('lodash');

/** Used to parse Newick strings. */
const parseNewick = require('newick-js').parse;
const newickJs = require('newick-js');

/** OWL terms to be used here. */
const owlterms = require('../utils/owlterms');
Expand Down Expand Up @@ -73,9 +73,9 @@ class PhylogenyWrapper {
});
}

// Finally, try parsing it with parseNewick and see if we get an error.
// Finally, try parsing it with newickJs.parse() and see if we get an error.
try {
parseNewick(newickTrimmed);
newickJs.parse(newickTrimmed);
} catch (ex) {
errors.push({
title: 'Error parsing phylogeny',
Expand Down Expand Up @@ -152,7 +152,7 @@ class PhylogenyWrapper {
// - 'both': Return node labels on both internal and terminal nodes.

// Parse the phylogeny (will throw an exception if parsing failed).
const { graph } = parseNewick(this.phylogeny.newick || '()');
const { graph } = newickJs.parse(this.phylogeny.newick || '()');
const [vertices, arcs] = graph;

if (nodeType === 'both') {
Expand Down Expand Up @@ -252,7 +252,7 @@ class PhylogenyWrapper {
// This method provides a similar facility using the newick-js library.
//
// Throws an exception if the Newick could not be parsed.
const { graph, root, rootWeight } = parseNewick(newick);
const { graph, root, rootWeight } = newickJs.parse(newick);
const [, arcs] = graph;

// Go through the arcs, assigning 'children' to the appropriate parent node.
Expand Down

0 comments on commit ec8c86b

Please sign in to comment.