Skip to content

Commit

Permalink
fix: use util.promisify instead of bluebird
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed May 12, 2019
1 parent 30a0915 commit 22e95a2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
44 changes: 23 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
},
"homepage": "https://github.com/linonetwo/zazu-firefox-bookmarks#readme",
"dependencies": {
"bluebird": "^3.5.4",
"fast-fuzzy": "^1.8.5",
"traverse": "^0.6.6"
"traverse": "^0.6.6",
"util.promisify": "^1.0.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
Expand Down
13 changes: 10 additions & 3 deletions src/bookmarkParser/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @ts-check
const Promise = require('bluebird');
const promisify = require('util.promisify');
const os = require('os');
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');

const readdirAsync = Promise.promisify(fs.readdir);
const execAsync = Promise.promisify(exec);
const readdirAsync = promisify(fs.readdir);
const execAsync = promisify(exec);

function bookmarkParser(version = 'default', pluginContext) {
let filePath;
Expand Down Expand Up @@ -36,6 +36,13 @@ function bookmarkParser(version = 'default', pluginContext) {
shellCommandToReadData,
});
return execAsync(shellCommandToReadData)
.then(({ stdout }) => {
if (!stdout) throw new Error('No stdout after exec');
if (typeof stdout === 'string') {
return stdout;
}
throw new Error(`Bad stdout type ${typeof stdout}`);
})
.then(JSON.parse)
.then(content => ({ filename, content }));
});
Expand Down

0 comments on commit 22e95a2

Please sign in to comment.