3 var shmatter = require('shmatter');
4 var fs = require('fs');
5 var path = require('path');
7 var pkgs = module.exports;
8 pkgs.create = function (Pkgs, basepath) {
13 basepath = path.join(__dirname, '../');
16 Pkgs.all = function () {
17 return fs.promises.readdir(basepath).then(function (nodes) {
20 .reduce(function (p, node) {
21 return p.then(function () {
22 return pkgs.get(node).then(function (meta) {
23 if (meta && '_' !== node[0]) {
36 Pkgs.get = function (node) {
37 var yash = path.join(basepath, node, 'package.yash');
38 var curlbash = path.join(basepath, node, 'install.sh');
39 var readme = path.join(basepath, node, 'README.md');
40 var winstall = path.join(basepath, node, 'install.bat');
43 .readFile(readme, 'utf-8')
44 .then(function (txt) {
46 //return frontmarker.parse(txt);
49 if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
50 console.error("failed to read '" + node + "/README.md'");
55 .readFile(yash, 'utf-8')
56 .then(function (txt) {
57 return shmatter.parse(txt);
60 // no yash package description
62 if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
63 console.error("failed to parse '" + node + "/package.yash'");
66 return fs.promises.readFile(curlbash, 'utf-8').then(function (txt) {
67 return shmatter.parse(txt);
73 if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
74 console.error("failed to parse '" + node + "/install.sh'");
78 fs.promises.access(winstall).catch(function (e) {
81 if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
82 console.error("failed to read '" + node + "/install.bat'");
86 ]).then(function (items) {
92 meta.windows = !!winstall;
93 meta.bash = !!curlbash;
103 if (module === require.main) {
104 pkgs.all().then(function (data) {
105 console.info('package info:');