yoshuawuyts / copy-template-dir
Showing 1 of 1 files from the diff.
Newly tracked file
index.js changed.

@@ -36,8 +36,14 @@
Loading
36 36
37 37
    // create a new stream for every file emitted
38 38
    rs.on('data', function (file) {
39 -
      createdFiles.push(path.join(outDir, maxstache(removeUnderscore(file.path), vars)))
40 -
      streams.push(writeFile(outDir, vars, file))
39 +
      const dotfile = new RegExp(/^[.].*$/).test(file.name)
40 +
      if (dotfile) {
41 +
        createdFiles.push(path.join(outDir, file.path, vars))
42 +
        streams.push(writeDotfile(outDir, vars, file))
43 +
      } else {
44 +
        createdFiles.push(path.join(outDir, maxstache(removeUnderscore(file.path), vars)))
45 +
        streams.push(writeFile(outDir, vars, file))
46 +
      }
41 47
    })
42 48
43 49
    // delegate errors & close streams
@@ -58,6 +64,7 @@
Loading
58 64
    const fileName = file.path
59 65
    const inFile = file.fullPath
60 66
    const parentDir = file.parentDir
67 +
61 68
    const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars))
62 69
63 70
    mkdirp(path.join(outDir, maxstache(parentDir, vars)), function (err) {
@@ -72,6 +79,26 @@
Loading
72 79
  }
73 80
}
74 81
82 +
// write a dotfile directly to a directory (no template)
83 +
// str -> stream
84 +
function writeDotfile (outDir, vars, file) {
85 +
  return function (done) {
86 +
    const fileName = file.path
87 +
    const inFile = file.fullPath
88 +
    const parentDir = file.parentDir
89 +
    const outFile = path.join(outDir, fileName, vars)
90 +
91 +
    mkdirp(path.join(outDir, parentDir), function (err) {
92 +
      if (err) return done(err)
93 +
94 +
      const rs = fs.createReadStream(inFile)
95 +
      const ws = fs.createWriteStream(outFile)
96 +
97 +
      pump(rs, ws, done)
98 +
    })
99 +
  }
100 +
}
101 +
75 102
// remove a leading underscore
76 103
// str -> str
77 104
function removeUnderscore (filepath) {
Files Coverage
index.js 81.54%
Project Totals (1 files) 81.54%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading