mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-05-18 02:59:17 +00:00
18 lines
479 B
JavaScript
18 lines
479 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const R = require('ramda');
|
|
const { DOMAINS_PATH } = require('./constants');
|
|
|
|
const toDomain = str => path.join(DOMAINS_PATH, str);
|
|
|
|
const toDomainData = R.compose(JSON.parse, R.toString, fs.readFileSync, toDomain);
|
|
|
|
const getDomains = () =>
|
|
fs.promises.readdir(DOMAINS_PATH, {})
|
|
.then(R.map(name => ({
|
|
...toDomainData(name),
|
|
name: name.replace(/\.json$/, ''),
|
|
})));
|
|
|
|
module.exports = { getDomains };
|