@8ms/helpers 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,5 @@ type CreateDirectory = {
5
5
  * Create a directory recursively.
6
6
  * Requires fs-extra
7
7
  */
8
- declare const createDirectory: ({ filePath }: CreateDirectory) => void;
8
+ declare const createDirectory: ({ filePath }: CreateDirectory) => Promise<unknown>;
9
9
  export default createDirectory;
@@ -5,9 +5,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * Requires fs-extra
6
6
  */
7
7
  const createDirectory = ({ filePath }) => {
8
- const fs = require('fs-extra');
9
- const path = require('path');
10
- const fileDir = path.parse(filePath).dir;
11
- fs.ensureDirSync(fileDir);
8
+ return new Promise(async (resolve, reject) => {
9
+ const fs = require('fs-extra');
10
+ const path = require('path');
11
+ const fileDir = path.parse(filePath).dir;
12
+ fs.ensureDirSync(fileDir);
13
+ resolve(true);
14
+ });
12
15
  };
13
16
  exports.default = createDirectory;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.2.7",
4
+ "version": "1.2.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -10,7 +10,7 @@ const createDirectory_1 = __importDefault(require("../file/createDirectory"));
10
10
  *
11
11
  * Requires fs-extra
12
12
  */
13
- const saveUrlContents = ({ filePath, url }) => {
13
+ const saveUrlContents = async ({ filePath, url }) => {
14
14
  const fs = require('fs-extra');
15
15
  return new Promise(async (resolve, reject) => {
16
16
  (0, axios_1.default)({
@@ -18,8 +18,8 @@ const saveUrlContents = ({ filePath, url }) => {
18
18
  url,
19
19
  responseType: "stream"
20
20
  })
21
- .then(function (response) {
22
- (0, createDirectory_1.default)({
21
+ .then(async (response) => {
22
+ await (0, createDirectory_1.default)({
23
23
  filePath,
24
24
  });
25
25
  response.data.pipe(fs.createWriteStream(filePath));