Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function resolvers(options, webpackResolver) {
var evaluator = new Evaluator(nodes.null, options);
var whenWebpackResolver = whenNodefn.lift(webpackResolver);
// Stylus's normal resolver for single files.
var stylusFile = function(context, path) {
// Stylus adds .styl to paths for normal "paths" lookup if it isn't there.
if (!/.styl$/.test(path)) {
path += '.styl';
}
var paths = options.paths.concat(context);
var found = utils.find(path, paths, options.filename)
if (found) {
return normalizePaths(found);
}
};
// Stylus's normal resolver for node_modules packages. Cannot locate paths
function resolveFileDeep(helpers, parentCache, source, fullPath) {
var resolvers = helpers.resolvers;
var readFile = helpers.readFile;
var contexts = parentCache.contexts;
var sources = parentCache.sources;
contexts = contexts || {};
var nestResolve = resolveFileDeep.bind(null, helpers, parentCache, null);
var context = path.dirname(fullPath);
readFile = whenNodefn.lift(readFile);
return when
.resolve(source || sources[fullPath] || readFile(fullPath))
// Cast the buffer from the cached input file system to a string.
.then(String)
// Store the source so that the evaluator doesn't need to touch the
// file system.
.then(function(_source) {
sources[fullPath] = _source;
return _source;
})
// Make sure the stylus functions/index.styl source is stored.
.then(partial(ensureFunctionsSource, sources))
// List imports and use its cache. The source file is translated into a
// list of imports. Where the source file came from isn't important for the
// list. The where is added by resolveMany with the context and resolvers.
var path = require('path');
var Datastore = require('nedb');
var db = new Datastore({
filename: path.join(__dirname, '/../id.db'),
autoload: true }
);
// You can issue commands right away
module.exports = {
find: nodefn.lift(_.bind(db.find, db)),
findOne: nodefn.lift(_.bind(db.findOne, db)),
remove: nodefn.lift(_.bind(db.remove, db)),
insert: nodefn.lift(_.bind(db.insert, db)),
update: nodefn.lift(_.bind(db.update, db))
};
* limitations under the License.
**/
/*
* This is modified by Megam Systems.
*/
var fs = require('fs');
var when = require('when');
var nodeFn = require('when/node/function');
var keys = require('when/keys');
var util = require('util');
var fspath = require("path");
var mkdirp = require("mkdirp");
var promiseDir = nodeFn.lift(mkdirp);
var settings;
var flowsFile;
var flowsFullPath;
var flowsPrev;
var credentialsFile;
var oldCredentialsFile;
var userDir;
var libDir;
var libFlowsDir;
function listFiles(dir) {
var dirs = {};
var files = [];
var dirCount = 0;
return nodeFn.call(fs.readdir, dir).then(function (contents) {
// Run it from the root cola dir:
// `node examples/todos/server.js`
//
// It will create a flat file called todos.json for storing todos, and
// start a static web server on port 8080. Point your browser at:
// `http://localhost:8080/examples/todos/`
//
var express = require('express');
var app = express();
var when = require('when');
var nodefn = require('when/node/function');
var fs = require('fs');
var readFile = nodefn.lift(fs.readFile);
var writeFile = nodefn.lift(fs.writeFile);
app.configure(function () {
// used to parse JSON object given in the body request
app.use(express.bodyParser());
app.use(express.static(process.cwd()));
app.use(express.directory(process.cwd()));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
var todos = readFile('todos.json')
.then(JSON.parse)
.otherwise(generateData);
makeJsonRestEndpoint(app, '/todos');
var levelup = require('level')
var generateID = require('./gen-id')
var lift = require('when/node/function').lift
var when = require('when')
var db = levelup(process.env.HOME + '/.pushnot.db')
var put = lift(db.put.bind(db))
var get = lift(db.get.bind(db))
exports.push = function(data) {
var id = generateID()
return put('d-' + id, data)
.then(function() { return put('m-latest', id) })
.then(function() { return id })
}
exports.latest = function() {
return get('m-latest')
}
exports.get = function(id) {
return get('d-' + id)
}
.then(function(paths) {
paths.forEach(styl.import.bind(styl));
paths.forEach(self.addDependency);
var readFile = whenNodefn.lift(pathCacheHelpers.readFile);
return when.reduce(paths, function(cache, filepath) {
return readFile(filepath)
.then(function(source) {
return PathCache.createFromFile(
pathCacheHelpers, cache, source.toString(), filepath
);
});
}, {
contexts: {},
sources: {},
imports: importsCache,
});
})
.then(function(cache) {
var gulp = require('gulp')
var when = require('when')
var lift = require('when/node/function').lift
var mkdirp = lift(require('mkdirp'))
var passthru = lift(require('passthru'))
var es = require('event-stream')
var fs = require('fs')
var rename = require('gulp-rename')
var uglify = require('gulp-uglify')
var concat = require('gulp-concat')
var ngmin = require('gulp-ngmin')
var rev = require('gulp-rev')
var minifyCSS = require('gulp-minify-css')
gulp.task('build', function() {
return mkdirp('build').then(function() {
return passthru('./node_modules/.bin/r.js -o app.build.js optimize=none out=build/main-built.js')
})
})
* This file is customized version of originial node-red's localfilesystem.js in node-red/red/runtime/storage folder
* localfilesystem.js file is responsible for storing node-red flows into file system and loading same from file system.
* This file has modified saveFlows and loadFlows - in fact it does nothing in both the cases.
* loadflow and saveflow is handled in api. Since this file is originally from node-red, we will ignore jshint errors
* Author : Atul/Ori
**/
var fs = require('fs-extra');
var when = require('when');
var nodeFn = require('when/node/function');
var fspath = require('path');
var mkdirp = fs.mkdirs;
var log = require('./logger')('db-storage-for-node-red');
var promiseDir = nodeFn.lift(mkdirp);
var settings;
var flowsFile;
var flowsFullPath;
var credentialsFile;
var credentialsFileBackup;
var oldCredentialsFile;
var sessionsFile;
var libDir;
var libFlowsDir;
var globalSettingsFile;
function getFileMeta(root, path) {
var fn = fspath.join(root, path);
var fd = fs.openSync(fn, 'r');
var size = fs.fstatSync(fd).size;