Skip to content

Commit

Permalink
Merge some bits of #365 into package, enabling package "type":"module"
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Dec 18, 2023
1 parent c93c392 commit dd7973e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
node_modules
dist
src/*.po.js
src/pkgVersion.js
coverage
.nyc_output
22 changes: 11 additions & 11 deletions package-lock.json

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

15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@hebcal/core",
"version": "5.0.2",
"version": "5.0.3",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
"Danny Sadinoff (https://github.com/dsadinoff)"
"Danny Sadinoff (https://github.com/dsadinoff)",
"Benny Powers (https://github.com/bennypowers)"
],
"keywords": [
"hebcal",
Expand All @@ -20,8 +21,13 @@
"zmanim"
],
"description": "A perpetual Jewish Calendar API",
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"type": "module",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"typings": "hebcal.d.ts",
"engines": {
"node": ">= 16.0.0"
Expand All @@ -40,9 +46,10 @@
],
"scripts": {
"build:rollup": "rollup -c",
"build": "npm run po2json && npm run build:rollup",
"build": "npm run po2json && npm run version && npm run build:rollup",
"prepublish": "npm run build",
"po2json": "node ./po2json.cjs po/*.po",
"version": "node ./version.cjs package.json src/pkgVersion.js",
"readme": "npx -p jsdoc-to-markdown jsdoc2md dist/index.js",
"pretest": "npm run build",
"lint": "eslint src",
Expand Down
12 changes: 5 additions & 7 deletions src/candles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import {Event, flags} from './event.js';
import {Locale} from './locale.js';
import {Zmanim} from './zmanim.js';

const days = {
FRI: 5,
SAT: 6,
};
const FRI = 5;
const SAT = 6;

/**
* @private
Expand All @@ -20,19 +18,19 @@ const days = {
*/
export function makeCandleEvent(e, hd, dow, location, options) {
let havdalahTitle = false;
let useHavdalahOffset = dow == days.SAT;
let useHavdalahOffset = dow === SAT;
let mask = e ? e.getFlags() : flags.LIGHT_CANDLES;
if (typeof e !== 'undefined') {
// if linked event && dow == FRI, use Candle lighting time & title
if (dow != days.FRI) {
if (dow !== FRI) {
if (mask & (flags.LIGHT_CANDLES_TZEIS | flags.CHANUKAH_CANDLES)) {
useHavdalahOffset = true;
} else if (mask & flags.YOM_TOV_ENDS) {
havdalahTitle = true;
useHavdalahOffset = true;
}
}
} else if (dow == days.SAT) {
} else if (dow === SAT) {
havdalahTitle = true;
mask = flags.LIGHT_CANDLES_TZEIS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {getBirthdayHD, getYahrzeitHD, greg, months} from '@hebcal/hdate';
import {version as pkgVersion} from '../package.json';
import {version as pkgVersion} from './pkgVersion.js';
import {DailyLearning} from './DailyLearning.js';
import {HebrewDateEvent} from './HebrewDateEvent.js';
import {ParshaEvent} from './ParshaEvent.js';
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export {HolidayEvent, AsaraBTevetEvent, MevarchimChodeshEvent,
RoshChodeshEvent, RoshHashanaEvent} from './holidays.js';
export {DailyLearning} from './DailyLearning.js';
export {HebrewCalendar} from './hebcal.js';
export {version} from '../package.json';
export {version} from './pkgVersion.js';
12 changes: 12 additions & 0 deletions version.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable require-jsdoc */
const fs = require('fs');

const inpath = process.argv[2];
const outpath = process.argv[3];

const contents = fs.readFileSync(inpath).toString();
const manifest = JSON.parse(contents);
const line = `// DO NOT EDIT THIS AUTO-GENERATED FILE!
export const version = '${manifest.version}';\n`;

fs.writeFileSync(outpath, line, {flags: 'w'});

0 comments on commit dd7973e

Please sign in to comment.