From 0227a97c6bc867eb690d4b1b50370734e18c25b3 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 9 Mar 2023 15:22:33 -0500 Subject: [PATCH] Add back main. Data-search does not import cli.js to write to file. --- src/cli.js | 4 +++- src/data-search.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index 749fbfa..770bf94 100755 --- a/src/cli.js +++ b/src/cli.js @@ -120,7 +120,7 @@ async function formatData (dataArray) { } } -async function main () { // eslint-disable-line no-unused-vars +async function main () { (program .name('hyper-recent') .description('A CLI to do hyper-recent feed analysis') @@ -150,3 +150,5 @@ async function main () { // eslint-disable-line no-unused-vars await program.parseAsync(); } + +main(); diff --git a/src/data-search.js b/src/data-search.js index a24058f..cd85359 100644 --- a/src/data-search.js +++ b/src/data-search.js @@ -1,16 +1,19 @@ #! /usr/bin/env node import _ from 'lodash'; import fs from 'fs'; +import { writeFile } from 'fs/promises'; import { format, sub } from 'date-fns'; import { download } from './download.js'; import { Search } from './search.js'; -import { writeFormattedJSON } from './cli.js'; /** * Download preprint data from BiorXiv and MedrXiv servers and perform search for preprints in each topic. * @returns {collection}, a JSON array of search results for each set topic. */ export async function getData () { + const formatJSON = obj => JSON.stringify(obj, null, 2); + const writeFormattedJSON = async (obj, file) => await writeFile(file, formatJSON(obj)); + // Set dates for past month const now = new Date(); const startOffset = { months: 1 };