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

kopy

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kopy - npm Package Compare versions

Comparing version 6.1.0 to 7.0.0

165

dist/kopy.common.js

@@ -6,6 +6,5 @@ 'use strict';

var path = _interopDefault(require('path'));
var Metalsmith = _interopDefault(require('metalsmith'));
var majo = _interopDefault(require('majo'));
var match = _interopDefault(require('minimatch'));
var inquirer = _interopDefault(require('inquirer'));
var asyncEach = _interopDefault(require('async.each'));
var match$1 = _interopDefault(require('multimatch'));

@@ -19,7 +18,7 @@ var isBinaryPath = _interopDefault(require('is-binary-path'));

/* eslint-disable no-new-func */
var fn = new Function('data', 'with (data) { return ' + exp + ' }');
var fn = new Function('data', `with (data) { return ${exp} }`);
try {
return fn(data);
} catch (err) {
console.error('Error when evaluating filter condition: ' + exp);
console.error(`Error when evaluating filter condition: ${exp}`);
}

@@ -29,23 +28,19 @@ }

// forked from https://github.com/vuejs/vue-cli/blob/master/lib/filter.js
function filter(files, filters, data, done) {
if (!filters) {
return done();
}
var fileNames = Object.keys(files);
Object.keys(filters).forEach(function (glob) {
fileNames.forEach(function (file) {
if (match(file, glob, { dot: true })) {
var condition = filters[glob];
if (!evalualte(condition, data)) {
delete files[file];
function filterFiles(filters) {
return function (ctx) {
if (!filters) return;
var fileList = ctx.fileList;
var data = ctx.meta.merged;
Object.keys(filters).forEach(function (glob) {
fileList.forEach(function (file) {
if (match(file, glob, { dot: true })) {
var condition = filters[glob];
if (!evalualte(condition, data)) {
ctx.deleteFile(file);
}
}
}
});
});
});
done();
}
function filterFiles(filters) {
return function (files, metalsmith, done) {
filter(files, filters, metalsmith.metadata().merged, done);
};

@@ -55,5 +50,5 @@ }

function ask(data, prompts) {
return function (files, metalsmith, done) {
return function (ctx) {
if (prompts) {
inquirer.prompt(prompts).then(function (answers) {
return inquirer.prompt(prompts).then(function (answers) {
var merged = Object.assign({}, data, answers);

@@ -89,11 +84,10 @@

metalsmith.metadata({ data: data, answers: answers, merged: merged });
done();
}).catch(done);
} else if (data) {
metalsmith.metadata({ data: data, merged: data });
done();
ctx.meta = { data, answers, merged };
});
}
if (data) {
ctx.meta = { data, merged: data };
} else {
metalsmith.metadata({ merged: {} });
done();
ctx.meta = { merged: {} };
}

@@ -111,4 +105,4 @@ };

return function (files, metalsmith, done) {
var keys = Object.keys(files);
return function (ctx) {
var fileList = ctx.fileList;
var matchedFile = void 0;

@@ -119,15 +113,15 @@ if (skipInterpolation) {

} else {
(function () {
var matches = match$1(keys, skipInterpolation);
matchedFile = function matchedFile(file) {
return matches.indexOf(file) !== -1;
};
})();
var matches = match$1(fileList, skipInterpolation);
matchedFile = function matchedFile(file) {
return matches.indexOf(file) !== -1;
};
}
}
asyncEach(keys, run, done);
return Promise.all(fileList.map(function (relative) {
return run(relative);
}));
function run(file, done) {
var content = files[file].contents.toString();
function run(file) {
var content = ctx.fileContents(file);

@@ -139,8 +133,7 @@ var shouldSkip = matchedFile && matchedFile(file, content);

if (shouldSkip || isBinaryPath(file)) {
return done();
return;
}
var res = require('jstransformer')(template).render(content, templateOptions, metalsmith.metadata().merged);
files[file].contents = new Buffer(res.body);
done();
var res = require('jstransformer')(template).render(content, templateOptions, ctx.meta.merged);
ctx.writeContents(file, res.body);
}

@@ -151,16 +144,14 @@ };

var skip = function (skipExisting, destPath) {
return function (files, metalsmith, done) {
Promise.all(Object.keys(files).map(function (name) {
return function (ctx) {
return Promise.all(ctx.fileList.map(function (name) {
var location = path.join(destPath, name);
return exists(location).then(function (yes) {
if (yes) {
delete files[name];
ctx.deleteFile(name);
if (typeof skipExisting === 'function') {
skipExisting(location);
skipExisting(location, name);
}
}
});
})).then(function () {
return done();
}).catch(done);
}));
};

@@ -170,9 +161,9 @@ };

var moveFiles = function (move) {
return function (files, metalsmith, done) {
if (!move) return done();
return function (ctx) {
if (!move) return;
for (var pattern in move) {
var matches = match.match(Object.keys(files), pattern);
var matches = match.match(ctx.fileList, pattern);
if (matches.length > 0) {
var content = files[matches[0]];
var file = ctx.file(matches[0]);
var _iteratorNormalCompletion = true;

@@ -186,3 +177,3 @@ var _didIteratorError = false;

delete files[match$$1];
ctx.deleteFile(match$$1);
}

@@ -205,7 +196,5 @@ } catch (err) {

var newName = move[pattern];
files[newName] = content;
ctx.createFile(newName, file);
}
}
done();
};

@@ -235,34 +224,34 @@ };

return new Promise(function (resolve, reject) {
var source = path.resolve(cwd, src);
var destPath = path.resolve(cwd, dest);
var pipe = Metalsmith(source); // eslint-disable-line new-cap
var destPath = path.resolve(cwd, dest);
var base = path.resolve(cwd, src);
var done = function done(err, files) {
if (err) return reject(err);
resolve(_extends({
files: files
}, pipe.metadata()));
};
var done = function done(stream) {
return _extends({
files: stream.files,
fileList: stream.fileList
}, stream.meta);
};
pipe.source('.').ignore(function (file) {
return (/\.DS_Store$/.test(file)
);
}).use(ask(data, prompts)).use(filterFiles(filters)).use(moveFiles(move));
var stream = majo();
if (!disableInterpolation) {
pipe.use(useTemplate({ skipInterpolation: skipInterpolation, template: template, templateOptions: templateOptions }));
}
stream.source('**', { cwd: base }).filter(function (file) {
return !/\.DS_Store$/.test(file);
}).use(ask(data, prompts)).use(filterFiles(filters)).use(moveFiles(move));
if (skipExisting) {
pipe.use(skip(skipExisting, destPath));
}
if (!disableInterpolation) {
stream.use(useTemplate({ skipInterpolation, template, templateOptions }));
}
pipe.clean(clean).destination(destPath);
if (skipExisting) {
stream.use(skip(skipExisting, destPath));
}
if (write === false) {
return pipe.process(done);
}
if (write === false) {
return stream.process().then(function () {
return done(stream);
});
}
pipe.build(done);
return stream.dest(destPath, { clean }).then(function () {
return done(stream);
});

@@ -269,0 +258,0 @@ }

{
"name": "kopy",
"version": "6.1.0",
"version": "7.0.0",
"description": "Gracefully copy a directory and render templates.",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "NODE_ENV=test ava && eslint src/*.js && rm -rf test/dest && npm run build",
"test": "NODE_ENV=test ava && xo && rm -rf test/dest && npm run build",
"build": "bili --js babel",

@@ -37,18 +37,18 @@ "example": "npm run build && mkdir -p dist-example && cd dist-example && node ../example.js"

"ava": "latest",
"babel-preset-env": "^1.4.0",
"babel-preset-stage-2": "^6.18.0",
"bili": "0.10.0",
"bili": "^0.14.2",
"ejs": "^2.5.5",
"eslint": "^3.9.1",
"eslint-config-rem": "^2.0.0",
"eslint-config-rem": "^3.0.1",
"jstransformer-handlebars": "^1.0.0",
"rimraf": "^2.5.4",
"rollup-plugin-babel": "^2.7.1"
"rollup-plugin-babel": "^2.7.1",
"xo": "^0.18.1"
},
"dependencies": {
"async.each": "^0.5.2",
"inquirer": "^2.0.0",
"inquirer": "^3.0.6",
"is-binary-path": "^2.0.0",
"jstransformer": "^1.0.0",
"jstransformer-ejs": "^0.0.3",
"metalsmith": "^2.2.0",
"majo": "^0.2.3",
"minimatch": "^3.0.3",

@@ -63,5 +63,8 @@ "multimatch": "^2.1.0",

},
"eslintConfig": {
"extends": "rem/esnext"
"xo": {
"extends": "rem",
"rules": {
"guard-for-in": 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