diff --git a/.gitignore b/.gitignore index 5c49d4c..957b1fa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ coverage/ tmp/ npm-debug.log* .DS_Store +.nyc_output +package-lock.json \ No newline at end of file diff --git a/index.js b/index.js index 8adac68..6a2d5d7 100644 --- a/index.js +++ b/index.js @@ -29,8 +29,7 @@ function copyTemplateDir (srcDir, outDir, vars, cb) { // create directory mkdirp(outDir, function (err) { if (err) return cb(err) - - const rs = readdirp({ root: srcDir }) + const rs = readdirp(srcDir, {}) const streams = [] const createdFiles = [] @@ -57,9 +56,9 @@ function writeFile (outDir, vars, file) { return function (done) { const fileName = file.path const inFile = file.fullPath - const parentDir = file.parentDir + const parentDir = path.basename(file.dirent.path) const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars)) - + mkdirp(path.join(outDir, maxstache(parentDir, vars)), function (err) { if (err) return done(err) diff --git a/package.json b/package.json index ad6a458..0323d1b 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "copy-template-dir", + "name": "@tsbb/copy-template-dir", "version": "1.4.0", "description": "High throughput template dir writes", "main": "index.js", "scripts": { "deps": "dependency-check . && dependency-check . --extra --no-dev", - "test": "standard && npm run deps && NODE_ENV=test node test", - "test:cov": "standard && npm run deps && NODE_ENV=test istanbul cover test/index.js" + "test": "npm run deps && NODE_ENV=test node test", + "test:cov": "npm run deps && NODE_ENV=test nyc tape test/index.js && nyc report --reporter=lcov" }, - "repository": "yoshuawuyts/copy-template-dir", + "repository": "tsbbjs/copy-template-dir", "keywords": [ "template", "directory", @@ -25,15 +25,15 @@ "mkdirp": "^0.5.1", "noop2": "^2.0.0", "pump": "^1.0.0", - "readdirp": "^2.0.0", - "run-parallel": "^1.1.4" + "readdirp": "^3.6.0", + "run-parallel": "^1.2.0" }, "devDependencies": { "concat-stream": "^1.5.0", "dependency-check": "^2.5.1", - "istanbul": "^0.3.21", + "istanbul": "^0.4.5", + "nyc": "^17.0.0", "rimraf": "^2.4.3", - "standard": "^5.3.1", "tape": "^4.2.0" }, "files": [ diff --git a/test/index.js b/test/index.js index d7f67ea..26366f3 100644 --- a/test/index.js +++ b/test/index.js @@ -40,7 +40,7 @@ test('should write a bunch of files', function (t) { return path.relative(outDir, filePath) }), 'reported as created') - readdirp({ root: outDir }).pipe(concat({ object: true }, function (arr) { + readdirp(outDir, { }).pipe(concat({ object: true }, function (arr) { t.ok(Array.isArray(arr), 'is array') const names = arr.map(function (file) { return file.path }) @@ -61,7 +61,7 @@ test('should inject context variables strings', function (t) { copy(inDir, outDir, { foo: 'bar' }, function (err) { t.error(err) - readdirp({ root: outDir }).pipe(concat({ object: true }, function (arr) { + readdirp(outDir, { }).pipe(concat({ object: true }, function (arr) { t.ok(Array.isArray(arr), 'is array') const file = path.join(outDir, '1.txt') @@ -86,8 +86,8 @@ test('should inject context variables strings into filenames', function (t) { const outDir = path.join(__dirname, '../tmp') copy(inDir, outDir, { foo: 'bar' }, function (err) { t.error(err) - - readdirp({ root: outDir }).pipe(concat({ object: true }, function (arr) { + + readdirp(outDir, { }).pipe(concat({ object: true }, function (arr) { t.ok(Array.isArray(arr), 'is array') const file = path.join(outDir, 'bar.txt') @@ -110,7 +110,7 @@ test('should inject context variables strings into directory names', function (t copy(inDir, outDir, { foo: 'bar' }, function (err) { t.error(err) - readdirp({ root: outDir }).pipe(concat({ object: true }, function (arr) { + readdirp(outDir, {}).pipe(concat({ object: true }, function (arr) { t.ok(Array.isArray(arr), 'is array') const dir = path.join(outDir, 'bar')