Skip to content

Commit

Permalink
feat: add getProfileNames
Browse files Browse the repository at this point in the history
  • Loading branch information
stepankuzmin committed Sep 18, 2018
1 parent a324c56 commit 4acc3c6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
const path = require('path');
const { spawn } = require('child_process');

Expand All @@ -13,6 +14,21 @@ const replaceExtension = (filePath, newExtension) => {
return path.join(path.dirname(filePath), newFileName);
};

const getProfileNames = () =>
new Promise((resolve, reject) =>
fs.readdir(osrmProfilesPath, (error, fileNames) => {
if (error) {
reject(error);
}

const profileNames = fileNames
.filter(fileName => path.extname(fileName) === '.lua')
.map(fileName => path.basename(fileName, '.lua'));

resolve(profileNames);
})
);

const extract = (extractPath, profileName, options = {}) =>
new Promise((resolve, reject) => {
const { stdoutStream, stderrStream } = options;
Expand Down Expand Up @@ -66,4 +82,4 @@ const contract = (graphPath, options = {}) =>
});
});

module.exports = { extract, contract };
module.exports = { getProfileNames, extract, contract };

0 comments on commit 4acc3c6

Please sign in to comment.