Commit a7b072ca authored by Nikolay Gromov's avatar Nikolay Gromov

Добавил в генератор создание папки для необрабатываемых картинок

parent 06403df4
...@@ -11,7 +11,7 @@ const dirs = projectConfig.dirs; ...@@ -11,7 +11,7 @@ const dirs = projectConfig.dirs;
const mkdirp = require('mkdirp'); const mkdirp = require('mkdirp');
const blockName = process.argv[2]; // получим имя блока const blockName = process.argv[2]; // получим имя блока
const defaultExtensions = ['scss', 'html', 'img']; // расширения по умолчанию const defaultExtensions = ['scss', 'html', 'img', 'bg-img']; // расширения по умолчанию
const extensions = uniqueArray(defaultExtensions.concat(process.argv.slice(3))); // добавим введенные при вызове расширения (если есть) const extensions = uniqueArray(defaultExtensions.concat(process.argv.slice(3))); // добавим введенные при вызове расширения (если есть)
// Если есть имя блока // Если есть имя блока
...@@ -78,8 +78,21 @@ if (blockName) { ...@@ -78,8 +78,21 @@ if (blockName) {
} }
} }
// Если нужна подпапка для необрабатываемых картинок
else if (extention === 'bg-img') {
const imgFolder = `${dirPath}bg-img/`;
if (fileExist(imgFolder) === false) {
mkdirp(imgFolder, (err) => {
if (err) console.error(err);
else console.log(`[NTH] Создание папки: ${imgFolder} (если отсутствует)`);
});
} else {
console.log(`[NTH] Папка ${imgFolder} НЕ создана (уже существует) `);
}
}
// Создаем файл, если он еще не существует // Создаем файл, если он еще не существует
if (fileExist(filePath) === false && extention !== 'img') { if (fileExist(filePath) === false && extention !== 'img' && extention !== 'bg-img') {
fs.writeFile(filePath, fileContent, (err) => { fs.writeFile(filePath, fileContent, (err) => {
if (err) { if (err) {
return console.log(`[NTH] Файл НЕ создан: ${err}`); return console.log(`[NTH] Файл НЕ создан: ${err}`);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"version": "2.0.1", "version": "2.0.1",
"description": "Start a library of blocks and technical solutions for HTML/CSS/js page layout.", "description": "Start a library of blocks and technical solutions for HTML/CSS/js page layout.",
"author": "Nikolay Gromov", "author": "Nikolay Gromov",
"license": "WTFPL",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/nicothin/NTH-start-project.git" "url": "https://github.com/nicothin/NTH-start-project.git"
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
"imagemin-pngquant": "^5.0.0", "imagemin-pngquant": "^5.0.0",
"lint-staged": "^4.3.0", "lint-staged": "^4.3.0",
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"mkdirp": "^0.5.1",
"postcss-image-inliner": "^1.0.6", "postcss-image-inliner": "^1.0.6",
"postcss-import": "^11.0.0", "postcss-import": "^11.0.0",
"postcss-inline-svg": "^3.0.0", "postcss-inline-svg": "^3.0.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment