Skip to content

Commit

Permalink
Merge pull request #132 from linkedconnections/development
Browse files Browse the repository at this point in the history
v2.0.3
  • Loading branch information
julianrojas87 authored Jul 5, 2022
2 parents 4e0eec3 + a39e512 commit 8672d77
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion lib/stores/StoreManager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const fs = require('fs');
const csv = require('fast-csv');
const util = require('util');
const ChildProcess = require('child_process');
const Store = require('./Store');
const Services = require('../services/calendar');

const exec = util.promisify(ChildProcess.exec);

module.exports = async function (outPath, storeType, isTest) {
// Step 2: Read all the required GTFS files in a streamed-fashion
const stops = fs.createReadStream(`${outPath}/stops.txt`, { encoding: 'utf8', objectMode: true })
Expand All @@ -28,7 +32,11 @@ module.exports = async function (outPath, storeType, isTest) {
.on('error', function (e) {
console.error(e);
});


// Check if calendar.txt exists, otherwise create a dummy file to prevent stream issue
if(!fs.existsSync(`${outPath}/calendar.txt`)) {
await exec('touch calendar.txt', { cwd: outPath });
}
const services = fs.createReadStream(`${outPath}/calendar.txt`, { encoding: 'utf8', objectMode: true })
.pipe(csv.parse({ objectMode: true, headers: true }))
.pipe(new Services(calendarDates, isTest))
Expand Down
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "gtfs2lc",
"version": "2.0.2",
"version": "2.0.3",
"description": "Mapping script from gtfs to (linked) connections",
"main": "lib/gtfs2lc.js",
"bin": {
Expand Down

0 comments on commit 8672d77

Please sign in to comment.