Compare commits

...

2 Commits

Author SHA1 Message Date
AJ ONeal 68e4de75bf 0.12.1 2020-11-08 20:49:01 -07:00
AJ ONeal bd548f16da bugfix Promise 2020-11-08 20:48:56 -07:00
7 changed files with 16 additions and 19 deletions

View File

@ -242,7 +242,7 @@ JavaScript module (or make requests to an API service that renders them for you)
```javascript ```javascript
var slim = exports.slimjs || require("slimjs"); var slim = exports.slimjs || require("slimjs");
function render(contentstr /*, desi*/) { function render(contentstr /*, desi*/) {
return PromiseA.resolve(slim(contentstr)); return Promise.resolve(slim(contentstr));
} }
Desirae.registerRenderer(".slim", render); Desirae.registerRenderer(".slim", render);

View File

@ -5,7 +5,7 @@
function create(Desi) { function create(Desi) {
// Chrome, Firefox, and even MSIE11+ all support crypto // Chrome, Firefox, and even MSIE11+ all support crypto
var crypto = window.crypto || window.msCrypto, var crypto = window.crypto || window.msCrypto,
PromiseA = window.Promise, Promise = window.Promise,
algos; algos;
// convenience mappings for common digest algorithms // convenience mappings for common digest algorithms
@ -111,7 +111,7 @@
function request() {} function request() {}
request.get = function (url /*, query*/) { request.get = function (url /*, query*/) {
// Return a new promise. // Return a new promise.
return new PromiseA(function (resolve, reject) { return new Promise(function (resolve, reject) {
// Do the usual XHR stuff // Do the usual XHR stuff
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.onload = function () { req.onload = function () {
@ -139,7 +139,7 @@
}; };
request.post = function (url /*, query*/, body) { request.post = function (url /*, query*/, body) {
// Return a new promise. // Return a new promise.
return new PromiseA(function (resolve, reject) { return new Promise(function (resolve, reject) {
// Do the usual XHR stuff // Do the usual XHR stuff
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.onload = function () { req.onload = function () {

View File

@ -1,7 +1,5 @@
"use strict"; "use strict";
var PromiseA = require("bluebird").Promise,
fs = PromiseA.promisifyAll(require("fs"));
function create(Desi, options) { function create(Desi, options) {
var fsapi = Desi.fsapi; var fsapi = Desi.fsapi;
options.blogdir = options.blogdir || options.working_path; options.blogdir = options.blogdir || options.working_path;

View File

@ -10,7 +10,7 @@ var safeResolve = require("../utils").safeResolve;
var sha1sum = function (str) { var sha1sum = function (str) {
return require("secret-utils").hashsum("sha1", str); return require("secret-utils").hashsum("sha1", str);
}; };
var fsExtra = PromiseA.promisifyAll(require("fs.extra")); var copyAll = require("util").promisify(require("fs.extra").copy);
//, tmpdir = require('os').tmpdir() //, tmpdir = require('os').tmpdir()
function strip(prefix, pathname) { function strip(prefix, pathname) {
@ -48,7 +48,7 @@ function walkDir(parent, sub, opts) {
return true; return true;
} }
return new PromiseA(function (resolve) { return new Promise(function (resolve) {
var walker = walk.walk(trueRoot); var walker = walk.walk(trueRoot);
walker.on("nodeError", function (filepath, stat, next) { walker.on("nodeError", function (filepath, stat, next) {
//stats.forEach(function (stat) { //stats.forEach(function (stat) {
@ -76,7 +76,7 @@ function walkDir(parent, sub, opts) {
var file; var file;
if (!filter(stat.name)) { if (!filter(stat.name)) {
return PromiseA.resolve(); return Promise.resolve();
} }
file = { file = {
@ -93,7 +93,7 @@ function walkDir(parent, sub, opts) {
files.push(file); files.push(file);
if (!(opts.sha1sum || opts.content)) { if (!(opts.sha1sum || opts.content)) {
return PromiseA.resolve(); return Promise.resolve();
} }
// TODO stream sha1 (for assets) // TODO stream sha1 (for assets)
@ -208,7 +208,7 @@ function copyfs(blogdir, files) {
//, filename = path.basename(dest) //, filename = path.basename(dest)
dirpaths[pathname] = true; dirpaths[pathname] = true;
return PromiseA.resolve(); return Promise.resolve();
}) })
.then(function () { .then(function () {
// TODO is it better to do this lazy-like or as a batch? // TODO is it better to do this lazy-like or as a batch?
@ -224,7 +224,7 @@ function copyfs(blogdir, files) {
// TODO allow delete? // TODO allow delete?
return forEachAsync(sources, function (source) { return forEachAsync(sources, function (source) {
return fsExtra return fsExtra
.copyAsync( .copyAll(
safeResolve(blogdir, source), safeResolve(blogdir, source),
safeResolve(blogdir, files[source]), safeResolve(blogdir, files[source]),
{ replace: true } { replace: true }
@ -276,7 +276,7 @@ function putfs(blogdir, files, options) {
dirpaths[pathname] = true; dirpaths[pathname] = true;
return PromiseA.resolve(); return Promise.resolve();
}) })
.then(function () { .then(function () {
// TODO is it better to do this lazy-like or as a batch? // TODO is it better to do this lazy-like or as a batch?

View File

@ -2,13 +2,12 @@
(function (exports) { (function (exports) {
"use strict"; "use strict";
var PromiseA = exports.Promise || require("bluebird").Promise;
function renderMd(contentstr /*, desi*/) { function renderMd(contentstr /*, desi*/) {
var markitdown = (exports.markdownit || require("markdown-it"))({ var markitdown = (exports.markdownit || require("markdown-it"))({
html: true, html: true,
linkify: true, linkify: true,
}); });
return PromiseA.resolve( return Promise.resolve(
markitdown.render(contentstr) markitdown.render(contentstr)
//.replace('"', '"') //.replace('"', '"')
//.replace(''', "'") //.replace(''', "'")
@ -18,7 +17,7 @@
function renderNoop(contentstr /*, desi*/) { function renderNoop(contentstr /*, desi*/) {
// hmmm... that was easy // hmmm... that was easy
return PromiseA.resolve(contentstr); return Promise.resolve(contentstr);
} }
function renderJade(contentstr, desi, options) { function renderJade(contentstr, desi, options) {
@ -30,7 +29,7 @@
var jade = exports.jade || require("jade"), var jade = exports.jade || require("jade"),
fn = jade.compile(contentstr, options), fn = jade.compile(contentstr, options),
html = fn(desi); html = fn(desi);
return PromiseA.resolve(html); return Promise.resolve(html);
} }
exports.DesiraeRenderMarkdown = renderMd.DesiraeRenderMarkdown = renderMd; exports.DesiraeRenderMarkdown = renderMd.DesiraeRenderMarkdown = renderMd;

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "desirae", "name": "desirae",
"version": "0.12.0", "version": "0.12.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "desirae", "name": "desirae",
"version": "0.12.0", "version": "0.12.1",
"description": "An in-browser static blog library and static site generator. Similar to Jekyll, Octopress, Nanoc, etc", "description": "An in-browser static blog library and static site generator. Similar to Jekyll, Octopress, Nanoc, etc",
"main": "desirae.js", "main": "desirae.js",
"scripts": { "scripts": {