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.1.0 to 4.2.0

test/fixtures/rename-file-expected/newname

8

example.js
'use strict'
var generify = require('./')
var source = './fixture/template'
var dest = '/tmp/generify'
var data = { hello: 'hello world' }
const generify = require('./')
const source = './fixture/template'
const dest = '/tmp/generify'
const data = { hello: 'hello world' }

@@ -8,0 +8,0 @@ generify(source, dest, data, function (err) {

@@ -9,6 +9,6 @@ #!/usr/bin/env node

const split = require('split2')
const mkdirp = require('mkdirp')
const pump = require('pump')
const os = require('os')
const { isBinaryFile } = require('isbinaryfile')
const { mkdir } = fs

@@ -18,4 +18,4 @@ module.exports = generify

function generify (source, dest, data, onFile, done) {
var count = 1 // the walker counts as 1
var copyFilesAsNamed = data.copyAsNamed
let count = 1 // the walker counts as 1
let copyFilesAsNamed = data.copyAsNamed
if (copyFilesAsNamed) {

@@ -26,3 +26,3 @@ delete data.copyAsNamed

}
var transforms = data.transforms
let transforms = data.transforms
if (transforms) {

@@ -46,3 +46,3 @@ delete data.transforms

.on('file', function (file) {
var relativePath
let relativePath
if (copyFilesAsNamed.includes(path.basename(file))) {

@@ -52,8 +52,10 @@ relativePath = path.relative(source, file)

relativePath = path.relative(source, file).replace(/^__/, '.')
relativePath = replacePath.bind({ source })(relativePath)
}
var destFile = path.join(dest, relativePath)
const destFile = path.join(dest, relativePath)
count++
mkdirp(path.dirname(destFile), function (err) {
mkdir(path.dirname(destFile), { recursive: true }, function (err) {
if (err) return complete(err)

@@ -96,2 +98,14 @@

function replacePath (relpath) {
const ctx = { source: this.source }
const matches = matchAll(relpath, /@([a-zA-Z/\\.]*?)@/g)
for (const [, key] of matches) {
relpath = relpath.replace(
new RegExp('@' + key + '@'),
replacer.bind({ ...ctx, key })
)
}
return relpath
}
function replaceLine (line) {

@@ -148,5 +162,5 @@ const ctx = { source: this.source, dest: this.dest }

var source = process.argv[2]
var dest = process.argv[3]
var json = {}
const source = process.argv[2]
const dest = process.argv[3]
let json = {}

@@ -153,0 +167,0 @@ if (process.argv[4]) {

{
"name": "generify",
"version": "4.1.0",
"version": "4.2.0",
"description": "A reusable project generator",

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

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

@@ -37,3 +37,2 @@ },

"isbinaryfile": "^4.0.2",
"mkdirp": "^0.5.0",
"pump": "^3.0.0",

@@ -40,0 +39,0 @@ "split2": "^3.0.0",

@@ -60,3 +60,25 @@ # generify  ![Build Status](https://github.com/mcollina/generify/workflows/ci/badge.svg)

### Files and Directories
files and directories located in the template folder may also be replaced. File and folder names wrapped with `@` delimiters will be replaced.
#### Example
Given a template with:
`/template/@foo@/@bar@.txt`
and data:
```js
const data = {
foo: 'hello',
bar: 'world'
}
```
The outputted file will be:
`<dest>/hello/world.txt`
### `__` handling

@@ -63,0 +85,0 @@

@@ -19,3 +19,3 @@ 'use strict'

function setup (fixture) {
var expectedPath = path.join(base, fixture + '-expected')
let expectedPath = path.join(base, fixture + '-expected')

@@ -31,5 +31,5 @@ fs.stat(expectedPath, (err, stat) => {

function prepareExpectedData (path, fixture, cb) {
var expected = {}
var files = []
var count = 0
const expected = {}
const files = []
let count = 0

@@ -64,4 +64,11 @@ walker(path)

var dest = path.join(process.cwd(), 'test-runs', testRun, fixture)
var data = { hello: 'hello world' }
const dest = path.join(process.cwd(), 'test-runs', testRun, fixture)
const data = {
hello: 'hello world',
testfilename: 'newname',
testdirname: 'newdir',
nested: {
bar: 'nest hello world'
}
}

@@ -85,3 +92,3 @@ if (fixture === 'init') {

var expectedSet = new Set(Object.keys(expected).map(f => f.replace(/^[/\\]+/, '')))
const expectedSet = new Set(Object.keys(expected).map(f => f.replace(/^[/\\]+/, '')))

@@ -88,0 +95,0 @@ function onFile (file) {

@@ -19,3 +19,3 @@ 'use strict'

function setup (fixture) {
var expectedPath = path.join(base, fixture + '-expected')
let expectedPath = path.join(base, fixture + '-expected')

@@ -31,5 +31,5 @@ fs.stat(expectedPath, (err, stat) => {

function prepareExpectedData (path, fixture, cb) {
var expected = {}
var files = []
var count = 0
const expected = {}
const files = []
let count = 0

@@ -46,5 +46,3 @@ walker(path)

}
expected[file.replace(path, '')] = data.toString()
count++

@@ -65,4 +63,11 @@ if (count === files.length) {

var dest = path.join(process.cwd(), 'test-runs', testRun, fixture)
var data = { hello: 'hello world' }
const dest = path.join(process.cwd(), 'test-runs', testRun, fixture)
const data = {
hello: 'hello world',
testfilename: 'newname',
testdirname: 'newdir',
nested: {
bar: 'nest hello world'
}
}

@@ -69,0 +74,0 @@ if (fixture === 'init') {

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