Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexo-fs

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-fs - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

77

lib/fs.js

@@ -11,3 +11,3 @@ var Promise = require('bluebird');

var rEOL = new RegExp(EOL, 'g');
var escapeRegex = util.escape.regex;
var escapeRegExp = util.escapeRegExp;

@@ -26,2 +26,4 @@ var statAsync = Promise.promisify(fs.stat);

function exists(path, callback){
if (!path) throw new TypeError('path is required!');
return new Promise(function(resolve, reject){

@@ -36,2 +38,4 @@ fs.exists(path, function(exist){

function mkdirs(path, callback){
if (!path) throw new TypeError('path is required!');
var parent = dirname(path);

@@ -49,2 +53,4 @@

function mkdirsSync(path){
if (!path) throw new TypeError('path is required!');
var parent = dirname(path);

@@ -58,2 +64,4 @@ var exist = fs.existsSync(parent);

function checkParent(path){
if (!path) throw new TypeError('path is required!');
var parent = dirname(path);

@@ -67,2 +75,4 @@

function checkParentSync(path){
if (!path) throw new TypeError('path is required!');
var parent = dirname(path);

@@ -81,2 +91,4 @@ var exist = fs.existsSync(parent);

function writeFile(path, data, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){

@@ -93,2 +105,4 @@ callback = options;

function writeFileSync(path, data, options){
if (!path) throw new TypeError('path is required!');
checkParentSync(path);

@@ -99,2 +113,4 @@ fs.writeFileSync(path, data, options);

function appendFile(path, data, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){

@@ -111,2 +127,4 @@ callback = options;

function appendFileSync(path, data, options){
if (!path) throw new TypeError('path is required!');
checkParentSync(path);

@@ -117,2 +135,5 @@ fs.appendFileSync(path, data, options);

function copyFile(src, dest, callback){
if (!src) throw new TypeError('src is required!');
if (!dest) throw new TypeError('dest is required!');
return checkParent(dest).then(function(){

@@ -231,2 +252,5 @@ return new Promise(function(resolve, reject){

function copyDir(src, dest, options, callback){
if (!src) throw new TypeError('src is required!');
if (!dest) throw new TypeError('dest is required!');
if (!callback && typeof options === 'function'){

@@ -254,2 +278,4 @@ callback = options;

function listDir(path, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){

@@ -264,2 +290,4 @@ callback = options;

function listDirSync(path, options, parent){
if (!path) throw new TypeError('path is required!');
options = options || {};

@@ -290,2 +318,4 @@ parent = parent || '';

function readFile(path, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){

@@ -297,3 +327,3 @@ callback = options;

options = options || {};
if (options.encoding == null) options.encoding = 'utf8';
if (!options.hasOwnProperty('encoding')) options.encoding = 'utf8';

@@ -310,4 +340,6 @@ return readFileAsync(path, options).then(function(content){

function readFileSync(path, options){
if (!path) throw new TypeError('path is required!');
options = options || {};
if (options.encoding == null) options.encoding = 'utf8';
if (!options.hasOwnProperty('encoding')) options.encoding = 'utf8';

@@ -345,2 +377,4 @@ var content = fs.readFileSync(path, options);

function emptyDir(path, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){

@@ -355,2 +389,4 @@ callback = options;

function emptyDirSync(path, options, parent){
if (!path) throw new TypeError('path is required!');
options = options || {};

@@ -380,2 +416,4 @@ parent = parent || '';

function rmdir(path, callback){
if (!path) throw new TypeError('path is required!');
return readdirAsync(path).map(function(item){

@@ -397,2 +435,4 @@ var childPath = join(path, item);

function rmdirSync(path){
if (!path) throw new TypeError('path is required!');
var files = fs.readdirSync(path);

@@ -417,2 +457,4 @@ var childPath;

function watch(path, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){

@@ -437,3 +479,3 @@ callback = options;

var basename = pathFn.basename(path, extname);
var regex = new RegExp('^' + escapeRegex(basename) + '(?:-(\\d+))?' + escapeRegex(extname) + '$');
var regex = new RegExp('^' + escapeRegExp(basename) + '(?:-(\\d+))?' + escapeRegExp(extname) + '$');
var item = '';

@@ -459,2 +501,4 @@ var num = -1;

function ensurePath(path, callback){
if (!path) throw new TypeError('path is required!');
return exists(path).then(function(exist){

@@ -470,2 +514,3 @@ if (!exist) return path;

function ensurePathSync(path){
if (!path) throw new TypeError('path is required!');
if (!fs.existsSync(path)) return path;

@@ -478,2 +523,22 @@

function ensureWriteStream(path, options, callback){
if (!path) throw new TypeError('path is required!');
if (!callback && typeof options === 'function'){
callback = options;
options = {};
}
return checkParent(path).then(function(){
return fs.createWriteStream(path, options);
}).nodeify(callback);
}
function ensureWriteStreamSync(path, options){
if (!path) throw new TypeError('path is required!');
checkParentSync(path);
return fs.createWriteStream(path, options);
}
// appendFile

@@ -519,2 +584,6 @@ exports.appendFile = appendFile;

// ensureWriteStream
exports.ensureWriteStream = ensureWriteStream;
exports.ensureWriteStreamSync = ensureWriteStreamSync;
// exists

@@ -521,0 +590,0 @@ exports.exists = exists;

12

package.json
{
"name": "hexo-fs",
"version": "0.0.8",
"version": "0.1.0",
"description": "File system module for Hexo.",

@@ -15,9 +15,3 @@ "main": "lib/fs",

},
"repository": {
"type": "git",
"url": "git://github.com/hexojs/fs.git"
},
"bugs": {
"url": "https://github.com/hexojs/fs/issues"
},
"repository": "hexojs/fs",
"homepage": "http://hexo.io/",

@@ -36,3 +30,3 @@ "keywords": [

"graceful-fs": "^3.0.4",
"hexo-util": "0.0.2"
"hexo-util": "^0.1.0"
},

@@ -39,0 +33,0 @@ "devDependencies": {

@@ -147,2 +147,10 @@ # fs

### ensureWriteStream(path, [options], [callback])
Creates the parent directories if they does not exist and returns a writable stream.
### ensureWriteStream(path, [options])
Synchronous version of `fs.ensureWriteStream`.
## License

@@ -149,0 +157,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc