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

machinepack-fs

Package Overview
Dependencies
Maintainers
5
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machinepack-fs - npm Package Compare versions

Comparing version 1.6.3 to 1.6.4

2

machines/cp.js

@@ -9,2 +9,3 @@ module.exports = {

example: '/Users/mikermcneil/.tmp/foo',
description: 'The path (relative or absolute) to the file or directory to copy.',
required: true

@@ -14,2 +15,3 @@ },

example: '/Users/mikermcneil/.tmp/bar',
description: 'The path (relative or absolute) to the directory in which to place the copied file(s). When copying a single file, a target filename may be specified.',
required: true

@@ -16,0 +18,0 @@ }

@@ -9,2 +9,3 @@ module.exports = {

example: '/Users/mikermcneil/.tmp/foo',
description: 'Path (relative or absolute) to the directory whose contents should be listed.',
required: true

@@ -15,2 +16,6 @@ },

example: 2
},
types: {
description: 'The types of directory entries to return (defaults to ["all"])',
example: ['file'],
}

@@ -35,10 +40,66 @@ },

var ls = require('list-directory-contents');
var path = require('path');
try {
if (typeof inputs.depth !== 'undefined') {
return exits.error('`depth` input is not supported yet! Please consider contributing :)');
var spinlock;
var results = [];
// Default depth to 0 (infinite recursion)
var depth = inputs.depth || 0;
// Get the depth of the directory we're walking, for comparison
var dirDepth = inputs.dir.split(path.sep).length;
// Default types to "all"
var types = inputs.types || 'all';
// Initialize the walker
var walker = require('walker')(inputs.dir)
// Skip directories that are deeper than requested
.filterDir(function(dir, stat) {
if (depth && dir.split(path.sep).length > (dirDepth + depth)) {
return false;
}
return true;
})
// Handle errors
.on('error', function (err){
if (spinlock) return;
spinlock = true;
return exits.error(err);
})
// When walking is done, return the results
.on('end', function (){
if (spinlock) return;
spinlock = true;
return exits.success(results);
});
// Include file entries if requested
if (types == 'all' || types.indexOf('file') > -1) {
walker.on('file', function (entry, stat) {
// Filter out files that are deeper than requested
if (!depth || (entry.split(path.sep).length <= (dirDepth + depth))) {
results.push(entry);
}
});
}
return ls(inputs.dir, exits);
// Include directory entries if requested
if (types == 'all' || types.indexOf('dir') > -1) {
walker.on('dir', function (entry, stat) {
if (entry===inputs.dir) return;
results.push(entry);
});
}
// Include symlink entries if requested
if (types == 'all' || types.indexOf('symlink') > -1) {
walker.on('symlink', function (entry, stat) {
if (entry===inputs.dir) return;
results.push(entry);
});
}
}

@@ -45,0 +106,0 @@ catch(e){

@@ -8,5 +8,7 @@ module.exports = {

string: {
description: 'Text to write to the file',
example: 'lots of words, utf8 things you know',
},
destination: {
description: 'Path (relative or absolute) to the file to write.',
example: '/Users/mikermcneil/.tmp/bar',

@@ -13,0 +15,0 @@ required: true

16

package.json
{
"name": "machinepack-fs",
"version": "1.6.3",
"version": "1.6.4",
"description": "Work with the local filesystem; list files, write files, etc.",

@@ -13,3 +13,5 @@ "scripts": {

],
"author": "Mike McNeil",
"author": {
"name": "Mike McNeil"
},
"license": "MIT",

@@ -22,3 +24,3 @@ "devDependencies": {

"fs-extra": "~0.10.0",
"list-directory-contents": "0.0.2",
"walker": "~1.0.6",
"machine": "^1.1.0",

@@ -43,3 +45,9 @@ "async": "^0.9.0"

]
}
},
"readme": "# machinepack-fs\n\nMachines for working with the local filesystem.\n\n## Installation\n\n```sh\n$ npm install machinepack-fs\n```\n\n## Basic Usage\n\n```javascript\nvar Filesystem = require('machinepack-fs');\n\nFilesystem.ls({\n dir: '/blah/foo/bar'\n})\n.exec(function (err, result) {\n // ...\n});\n```\n\nFor more info about working with machines, see the [node-machine.org](http://node-machine.org).\n\n\n## License\n\nMIT &copy; Mike McNeil 2014\n",
"readmeFilename": "README.md",
"_id": "machinepack-fs@1.6.3",
"_shasum": "732bfd3733fdeb8fb523b5480bf25c701b674a1a",
"_from": "machinepack-fs@^1.3.4",
"_resolved": "https://registry.npmjs.org/machinepack-fs/-/machinepack-fs-1.6.3.tgz"
}
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