Created
February 2, 2016 12:40
-
-
Save maximkoretskiy/88f6c5bf5f91f22a15cc to your computer and use it in GitHub Desktop.
Fast add package json for all views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
const glob = require('glob'); | |
const path = require('path'); | |
const fs = require('fs'); | |
glob('app/scripts/view/**/*.coffee', function (err, files) { | |
files = files | |
.filter(f=> f.match(/\/(\w+)\/\1/i)) | |
.map(path.parse) | |
.forEach(f=>{ | |
const packageLocation = path.resolve(`${f.dir}/package.json`); | |
const packageContent = `{\n "main": "./${f.base}" \n}`; | |
fs.writeFileSync(packageLocation, packageContent) | |
console.info(`Write package.js in folder ${f.dir}`); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment