Socket
Socket
Sign inDemoInstall

fs-jetpack

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

8

CHANGELOG.md

@@ -0,1 +1,9 @@

0.5.2 (2014-09-21)
-------------------
* `inspect()` checksum of empty file is now `null`.
0.5.1 (2014-09-21)
-------------------
* `cwd()` accepts many arguments as path parts.
0.5.0 (2014-08-31)

@@ -2,0 +10,0 @@ -------------------

40

lib/inspector.js

@@ -45,3 +45,10 @@ "use strict";

var fileChecksum = function (path, algo) {
var fileChecksum = function (path, stat, algo) {
if (stat.size === 0) {
return {
type: algo,
value: null
};
}
var hash = crypto.createHash(algo);

@@ -72,3 +79,3 @@ var data = fs.readFileSync(path);

if (stat.isFile() && options.checksum) {
var computedChecksum = fileChecksum(path, options.checksum);
var computedChecksum = fileChecksum(path, stat, options.checksum);
}

@@ -136,17 +143,24 @@

var fileChecksumAsync = function (path, algo) {
var fileChecksumAsync = function (path, stat, algo) {
var deferred = Q.defer();
var hash = crypto.createHash(algo);
var s = fs.createReadStream(path);
s.on('data', function(data) {
hash.update(data);
});
s.on('end', function() {
if (stat.size === 0) {
deferred.resolve({
type: algo,
value: hash.digest('hex')
value: null
});
});
s.on('error', deferred.reject);
} else {
var hash = crypto.createHash(algo);
var s = fs.createReadStream(path);
s.on('data', function(data) {
hash.update(data);
});
s.on('end', function() {
deferred.resolve({
type: algo,
value: hash.digest('hex')
});
});
s.on('error', deferred.reject);
}

@@ -166,3 +180,3 @@ return deferred.promise;

// Have to count checksum
fileChecksumAsync(path, options.checksum)
fileChecksumAsync(path, stat, options.checksum)
.then(function (computedChecksum) {

@@ -169,0 +183,0 @@ deferred.resolve(createInspectObj(path, stat, computedChecksum));

{
"name": "fs-jetpack",
"description": "Higher level API for 'fs' library",
"version": "0.5.1",
"version": "0.5.2",
"author": "Jakub Szwacz <jakub@szwacz.com>",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -43,3 +43,3 @@ fs-jetpack

* [createWriteStream(path, [options])](#create-write-stream)
* [cwd([path])](#cwd)
* [cwd([path...])](#cwd)
* [dir(path, [criteria])](#dir)

@@ -114,8 +114,8 @@ * [exists(path)](#exists)

## <a name="cwd"></a> cwd([path])
## <a name="cwd"></a> cwd([path...])
Returns Current Working Directory (CWD) for this instance of jetpack, or creates new jetpack object with given path as its internal CWD.
**Note:** fs-jetpack never changes value of `process.cwd()`, the CWD we are talking about here is internal value inside every jetpack instance, and could be completely different than `process.cwd()`.
**Note:** fs-jetpack never changes value of `process.cwd()`, the CWD we are talking about here is internal value inside every jetpack instance.
**parameters:**
`path` (optional) path to become new CWD. Could be absolute, or relative. If relative path given new CWD will be resolved basing on current CWD of this jetpack instance.
`path...` (optional) path (or many path parts) to become new CWD. Could be absolute, or relative. If relative path given new CWD will be resolved basing on current CWD of this jetpack instance.

@@ -142,2 +142,6 @@ **returns:**

console.log(jetParentParent.cwd()); // '/one'
// When many parameters specified they are treated as parts of path to resolve
var sillyCwd = jetpack.cwd('a', 'b', 'c');
console.log(sillyCwd.cwd()); // '/one/two/three/a/b/c'
```

@@ -144,0 +148,0 @@

@@ -16,2 +16,3 @@ "use strict";

fse.mkdirsSync('dir/empty');
fse.outputFileSync('dir/empty.txt', '');
fse.outputFileSync('dir/file.txt', 'abc');

@@ -132,3 +133,3 @@ fse.outputFileSync('dir/subdir/file.txt', 'defg');

function expectations(data) {
expect(data).toEqual(['empty', 'file.txt', 'subdir']);
expect(data).toEqual(['empty', 'empty.txt', 'file.txt', 'subdir']);
}

@@ -156,2 +157,6 @@

},{
name: 'empty.txt',
type: 'file',
size: 0,
},{
name: 'file.txt',

@@ -187,2 +192,7 @@ type: 'file',

},{
name: 'empty.txt',
type: 'file',
size: 0,
md5: null
},{
name: 'file.txt',

@@ -242,2 +252,6 @@ type: 'file',

},{
name: 'empty.txt',
type: 'file',
size: 0
},{
name: 'file.txt',

@@ -281,4 +295,4 @@ type: 'file',

size: 7,
md5: '0dc3266b245151cda5c56c7f62439202',
// md5 of 'emptyfile.txt900150983cd24fb0d6963f7d28e17f72subdir11c68d9ad988ff4d98768193ab66a646'
md5: '12af23a5cc653373a081942b5e33ea61',
// md5 of 'emptyempty.txtfile.txt900150983cd24fb0d6963f7d28e17f72subdir11c68d9ad988ff4d98768193ab66a646'
children: [

@@ -292,2 +306,7 @@ {

},{
name: 'empty.txt',
type: 'file',
size: 0,
md5: null
},{
name: 'file.txt',

@@ -294,0 +313,0 @@ type: 'file',

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc