feature(delta): use WEBI_UA for curl.exe
[webi-installers/.git] / _webi / packages.js
index 603dc14b08a4af91904722c6e37b6a5007628800..bdfec061f18c79432790799549e6a9474935571f 100644 (file)
@@ -1,5 +1,6 @@
 'use strict';
 
+var frontmarker = require('./frontmarker.js');
 var shmatter = require('shmatter');
 var fs = require('fs');
 var path = require('path');
@@ -34,16 +35,21 @@ pkgs.create = function (Pkgs, basepath) {
   };
 
   Pkgs.get = function (node) {
+    return fs.promises.access(path.join(basepath, node)).then(function () {
+      return Pkgs._get(node);
+    });
+  };
+  Pkgs._get = function (node) {
     var yash = path.join(basepath, node, 'package.yash');
     var curlbash = path.join(basepath, node, 'install.sh');
     var readme = path.join(basepath, node, 'README.md');
-    var winstall = path.join(basepath, node, 'install.bat');
+    var winstall = path.join(basepath, node, 'install.ps1');
     return Promise.all([
       fs.promises
         .readFile(readme, 'utf-8')
         .then(function (txt) {
           // TODO
-          //return frontmarker.parse(txt);
+          return frontmarker.parse(txt);
         })
         .catch(function (e) {
           if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
@@ -79,12 +85,12 @@ pkgs.create = function (Pkgs, basepath) {
         // no winstaller
         winstall = '';
         if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
-          console.error("failed to read '" + node + "/install.bat'");
+          console.error("failed to read '" + node + "/install.ps1'");
           console.error(e);
         }
       })
     ]).then(function (items) {
-      var meta = items[1];
+      var meta = items[0] || items[1];
       if (!meta) {
         // doesn't exist
         return;