New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fairmont

Package Overview
Dependencies
Maintainers
3
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fairmont - npm Package Compare versions

Comparing version 1.0.0-beta-10 to 1.0.0-beta-11

254

lib/fs.js
// Generated by CoffeeScript 1.9.3
(function() {
var assert, async, call, describe, fs, ref, ref1,
var FS, assert, async, describe, init, initFS, ref,
slice = [].slice,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
ref = require("./generator"), call = ref.call, async = ref.async;
async = require("./generator").async;
fs = function(f) {
var liftAll;
liftAll = require("when/node").liftAll;
return f(liftAll(require("fs")), {
call: call,
async: async
});
FS = void 0;
initFS = function() {
return FS != null ? FS : FS = (function() {
var liftAll;
liftAll = require("when/node").liftAll;
return liftAll(require("fs"));
})();
};
ref1 = require("./helpers"), describe = ref1.describe, assert = ref1.assert;
init = function(f) {
return function() {
var ax;
ax = 1 <= arguments.length ? slice.call(arguments, 0) : [];
initFS();
return f.apply(null, ax);
};
};
ref = require("./helpers"), describe = ref.describe, assert = ref.assert;
describe("File system functions", function(context) {
var binary, chdir, curry, dirname, exist, exists, is_directory, is_file, lines, mkdir, mkdirp, read, read_buffer, read_stream, readdir, ref2, rm, rmdir, stat, stream, write;
stat = function(path) {
return fs(function(arg) {
var stat;
stat = arg.stat;
return stat(path);
});
};
var Minimatch, binary, chdir, curry, dirname, exist, exists, flatten, glob, is_directory, is_file, join, lines, ls, lsR, mkdir, mkdirp, read, read_buffer, read_stream, readdir, ref1, ref2, rm, rmdir, stat, stream, write;
stat = init(function(path) {
return FS.stat(path);
});
context.test("stat", function*() {
return assert(((yield stat("test/test.json"))).size != null);
});
exists = exist = function(path) {
return fs(function(arg) {
var stat;
stat = arg.stat;
return call(function*() {
try {
(yield stat(path));
return true;
} catch (_error) {
return false;
}
});
});
};
exists = exist = init(async(function*(path) {
try {
(yield FS.stat(path));
return true;
} catch (_error) {
return false;
}
}));
context.test("exists", function*() {

@@ -49,41 +50,73 @@ assert((yield exists("test/test.json")));

});
read = function(path, encoding) {
read = init(async(function*(path, encoding) {
if (encoding == null) {
encoding = 'utf8';
}
return fs(function(arg, arg1) {
var call, readFile;
readFile = arg.readFile;
call = arg1.call;
return call(function*() {
return (yield readFile(path, encoding));
});
});
};
return (yield FS.readFile(path, encoding));
}));
context.test("read", function*() {
return assert((JSON.parse((yield read("test/test.json")))).name === "fairmont");
});
read_buffer = function(path) {
return fs(function(arg, arg1) {
var call, readFile;
readFile = arg.readFile;
call = arg1.call;
return call(function*() {
return (yield readFile(path));
});
});
};
read_buffer = init(async(function*(path) {
return (yield FS.readFile(path));
}));
context.test("read_buffer", function*() {
return assert(((yield read_buffer("test/test.json"))).constructor.name === "Buffer");
return assert(((yield read_buffer("test/test.json"))).constructor === Buffer);
});
readdir = function(path) {
return fs(function(arg) {
var readdir;
readdir = arg.readdir;
return readdir(path);
});
};
ls = readdir = init(function(path) {
return FS.readdir(path);
});
context.test("readdir", function*() {
return assert(indexOf.call((yield readdir("test")), "test.json") >= 0);
});
flatten = require("./iterator").flatten;
join = require("path").join;
lsR = init(async(function*(path, visited) {
var childPath, file, i, info, len, ref1;
if (visited == null) {
visited = [];
}
ref1 = (yield readdir(path));
for (i = 0, len = ref1.length; i < len; i++) {
file = ref1[i];
childPath = join(path, file);
if (!(indexOf.call(visited, childPath) >= 0)) {
info = (yield FS.lstat(childPath));
if (info.isDirectory()) {
(yield lsR(childPath, visited));
} else {
visited.push(childPath);
}
}
}
return visited;
}));
context.test("lsR", function*() {
var ref1, resolve, testDir;
resolve = require("path").resolve;
testDir = join(__dirname, "..");
return assert((ref1 = join(testDir, "test/test.json"), indexOf.call((yield lsR(testDir)), ref1) >= 0));
});
Minimatch = require("minimatch").Minimatch;
glob = init(async(function*(pattern, path) {
var _path, i, len, match, minimatch, ref1, results;
minimatch = new Minimatch(pattern);
match = function(path) {
return minimatch.match(path);
};
ref1 = (yield lsR(path));
results = [];
for (i = 0, len = ref1.length; i < len; i++) {
_path = ref1[i];
if (match(_path)) {
results.push(_path);
}
}
return results;
}));
context.test("glob", function*() {
var ref1, testDir;
testDir = join(__dirname, "..");
return assert((ref1 = join(testDir, "test", "test.litcoffee"), indexOf.call((yield glob("**/*.litcoffee", testDir)), ref1) >= 0));
});
read_stream = function(stream) {

@@ -179,9 +212,5 @@ var buffer, promise;

});
write = function(path, content) {
return fs(function(arg) {
var writeFile;
writeFile = arg.writeFile;
return writeFile(path, content);
});
};
write = init(function(path, content) {
return FS.writeFile(path, content);
});
context.test("write", function*() {

@@ -191,74 +220,42 @@ return write("test/test.json", (yield read("test/test.json")));

chdir = function(dir, fn) {
return fs(function*(arg, arg1) {
var async, cwd, rval;
arg;
async = arg1.async;
cwd = process.cwd();
process.chdir(dir);
rval = (yield fn());
process.chdir(cwd);
return rval;
});
var cwd;
cwd = process.cwd();
process.chdir(dir);
fn();
return process.chdir(cwd);
};
fs(function(arg, arg1) {
var async;
arg;
async = arg1.async;
return context.test("chdir", function*() {
(yield chdir("test", async(function*() {
return assert((yield exists("test.json")));
})));
return assert((process.cwd().match(/test$/)) == null);
context.test("chdir", function() {
var cwd;
cwd = process.cwd();
chdir("test", function() {
var fs;
fs = require("fs");
return assert((fs.statSync("test.json")).size != null);
});
return assert(cwd === process.cwd());
});
rm = function(path) {
return fs(function(arg) {
var unlink;
unlink = arg.unlink;
return unlink(path);
});
};
rm = init(async(function(path) {
return FS.unlink(path);
}));
context.test("rm");
rmdir = function(path) {
return fs(function(arg) {
var rmdir;
rmdir = arg.rmdir;
return rmdir(path);
});
};
rmdir = init(function(path) {
return FS.rmdir(path);
});
context.test("rmdir", function() {});
is_directory = function(path) {
return fs(function(arg, arg1) {
var call, stat;
stat = arg.stat;
call = arg1.call;
return call(function*() {
return ((yield stat(path))).isDirectory();
});
});
};
is_directory = init(async(function*(path) {
return ((yield stat(path))).isDirectory();
}));
context.test("is_directory", function*() {
return assert((yield is_directory("./test")));
});
is_file = function(path) {
return fs(function(arg, arg1) {
var call, stat;
stat = arg.stat;
call = arg1.call;
return call(function*() {
return ((yield stat(path))).isFile();
});
});
};
is_file = init(async(function*(path) {
return ((yield stat(path))).isFile();
}));
context.test("is_file", function*() {
return assert((yield is_file("./test/test.json")));
});
ref2 = require("./core"), curry = ref2.curry, binary = ref2.binary;
mkdir = curry(function(mode, path) {
return fs(function(arg) {
var mkdir;
mkdir = arg.mkdir;
return mkdir(path, mode);
});
});
ref1 = require("./core"), curry = ref1.curry, binary = ref1.binary;
mkdir = curry(binary(init(function(mode, path) {
return FS.mkdir(path, mode);
})));
context.test("mdkir", function*() {

@@ -270,2 +267,3 @@ (yield mkdir('0777', "./test/foobar"));

dirname = require("path").dirname;
ref2 = require("./core"), curry = ref2.curry, binary = ref2.binary;
mkdirp = curry(binary(async(function*(mode, path) {

@@ -272,0 +270,0 @@ var parent;

{
"name": "fairmont",
"version": "1.0.0-beta-10",
"version": "1.0.0-beta-11",
"description": "A collection of useful functions and utilities.",

@@ -15,3 +15,4 @@ "files": [

"watch": "coffee --nodejs --harmony -o lib/ -cw src/*.*coffee",
"tag": "(node_modules/.bin/json -f package.json version | tee VERSION | xargs -I version git tag -am version version) && git push --tags"
"version": "(node_modules/.bin/json -f package.json version > VERSION)",
"tag": "(cat VERSION | xargs -I version git tag -am version version) && git push --tags"
},

@@ -38,2 +39,3 @@ "repository": {

"byline": "^4.2.1",
"minimatch": "^2.0.8",
"when": "^3.7.2"

@@ -40,0 +42,0 @@ },

Sorry, the diff of this file is not supported yet

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