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

generify

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generify - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

test/fixtures/nested-expected/a

35

generify.js

@@ -18,3 +18,2 @@ #!/usr/bin/env node

var count = 1 // the walker counts as 1
var keys = Object.keys(data)
var copyFilesAsNamed = data.copyAsNamed

@@ -84,3 +83,3 @@ if (copyFilesAsNamed) {

if (transforms[this.key]) {
return transforms[this.key](data[this.key], {
return transforms[this.key](getNestedValue(data, this.key), {
souce: this.source,

@@ -91,3 +90,3 @@ dest: this.dest,

}
return data[this.key]
return getNestedValue(data, this.key)
}

@@ -97,8 +96,9 @@

const ctx = { source: this.source, dest: this.dest }
keys.forEach(function (key) {
const matches = matchAll(line, /__([a-zA-Z/\\.]*?)__/g)
for (const match of matches) {
line = line.replace(
new RegExp('__' + key + '__', 'g'),
replacer.bind({ ...ctx, key })
new RegExp('__' + match[1] + '__', 'g'),
replacer.bind({ ...ctx, key: match[1] })
)
})
}
return line + os.EOL

@@ -119,2 +119,23 @@ }

/**
* Added for support of node versions < 12, since String.prototype.matchAll is only node >= 12
*/
function * matchAll (str, regexp) {
const flags = regexp.global ? regexp.flags : regexp.flags + 'g'
const re = new RegExp(regexp, flags)
let match
while ((match = re.exec(str))) {
yield match
}
}
function getNestedValue (obj, key) {
return key.split('.').reduce(function (result, key) {
if (!result || !key) {
return 'notFound'
}
return result[key]
}, obj)
}
function execute () {

@@ -121,0 +142,0 @@ if (process.argv.length < 4) {

4

package.json
{
"name": "generify",
"version": "4.0.0",
"version": "4.1.0",
"description": "A reusable project generator",

@@ -31,3 +31,3 @@ "main": "generify.js",

"snazzy": "^8.0.0",
"standard": "^14.0.0",
"standard": "^14.3.3",
"tap": "^14.0.0"

@@ -34,0 +34,0 @@ },

@@ -78,2 +78,6 @@ 'use strict'

if (fixture === 'nested') {
data.foo = { more: { nesting: 'oh gee' } }
}
var expectedSet = new Set(Object.keys(expected).map(f => f.replace(/^[/\\]+/, '')))

@@ -80,0 +84,0 @@

@@ -78,2 +78,6 @@ 'use strict'

if (fixture === 'nested') {
data.foo = { more: { nesting: 'oh gee' } }
}
generify(path.join(base, fixture), dest, data, function (err) {

@@ -80,0 +84,0 @@ t.notOk(err, 'no error')

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