Comparing version 0.9.1 to 0.10.0
/// <reference types="node" /> | ||
import fs from 'fs-extra'; | ||
import fs from 'fs'; | ||
import glob from 'fast-glob'; | ||
import ensureDir from 'mkdirp'; | ||
export declare type Middleware = (ctx: Majo) => Promise<void> | void; | ||
declare const remove: (arg1: string) => Promise<void>; | ||
export interface File { | ||
@@ -134,2 +136,10 @@ /** The absolute path of the file */ | ||
declare const majo: () => Majo; | ||
export { majo, fs, glob }; | ||
export { majo, remove, glob, ensureDir }; | ||
/** | ||
* Ensure directory exists before writing file | ||
*/ | ||
export declare const outputFile: (filepath: string, data: any, options?: string | { | ||
encoding?: string | null | undefined; | ||
mode?: string | number | undefined; | ||
flag?: string | undefined; | ||
} | null | undefined) => Promise<void>; |
@@ -8,4 +8,7 @@ 'use strict'; | ||
var path = _interopDefault(require('path')); | ||
var fs = _interopDefault(require('fs-extra')); | ||
var fs = _interopDefault(require('fs')); | ||
var util = require('util'); | ||
var glob = _interopDefault(require('fast-glob')); | ||
var rimraf = _interopDefault(require('rimraf')); | ||
var ensureDir = _interopDefault(require('mkdirp')); | ||
@@ -27,2 +30,5 @@ class Wares { | ||
const readFile = util.promisify(fs.readFile); | ||
const writeFile = util.promisify(fs.writeFile); | ||
const remove = util.promisify(rimraf); | ||
class Majo { | ||
@@ -70,3 +76,3 @@ constructor() { | ||
const absolutePath = path.resolve(this.baseDir, entry.path); | ||
return fs.readFile(absolutePath).then(contents => { | ||
return readFile(absolutePath).then(contents => { | ||
const file = { | ||
@@ -119,3 +125,3 @@ contents, | ||
if (clean) { | ||
await fs.remove(destPath); | ||
await remove(destPath); | ||
} | ||
@@ -128,5 +134,3 @@ await Promise.all(Object.keys(this.files).map(filename => { | ||
} | ||
return fs | ||
.ensureDir(path.dirname(target)) | ||
.then(() => fs.writeFile(target, contents)); | ||
return ensureDir(path.dirname(target)).then(() => writeFile(target, contents)); | ||
})); | ||
@@ -203,6 +207,12 @@ return this; | ||
const majo = () => new Majo(); | ||
/** | ||
* Ensure directory exists before writing file | ||
*/ | ||
const outputFile = (filepath, data, options) => ensureDir(path.dirname(filepath)).then(() => writeFile(filepath, data, options)); | ||
exports.fs = fs; | ||
exports.glob = glob; | ||
exports.ensureDir = ensureDir; | ||
exports.Majo = Majo; | ||
exports.majo = majo; | ||
exports.outputFile = outputFile; | ||
exports.remove = remove; |
{ | ||
"name": "majo", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"description": "A minimal module to manipulate files.", | ||
@@ -38,3 +38,5 @@ "repository": { | ||
"@types/jest": "^24.0.23", | ||
"@types/mkdirp": "^1.0.0", | ||
"@types/node": "^12.12.7", | ||
"@types/rimraf": "^3.0.0", | ||
"husky": "^3.0.9", | ||
@@ -52,4 +54,5 @@ "jest": "^24.9.0", | ||
"fast-glob": "^3.1.0", | ||
"fs-extra": "^8.1.0" | ||
"mkdirp": "^1.0.4", | ||
"rimraf": "^3.0.2" | ||
} | ||
} |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
15947
363
3
14
+ Addedmkdirp@^1.0.4
+ Addedrimraf@^3.0.2
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedfs-extra@^8.1.0
- Removedfs-extra@8.1.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removeduniversalify@0.1.2(transitive)