create-node-template
Version:
Create node.js/express boilerplate with one command
55 lines • 1.62 kB
JavaScript
// import { blue, green } from 'picocolors';
import { blue, green } from '../../../utils/index.js';
import fs from 'fs';
import path from 'path';
export function isFolderEmpty(root, name) {
const validFiles = [
'.DS_Store',
'.git',
'.gitattributes',
'.gitignore',
'.gitlab-ci.yml',
'.hg',
'.hgcheck',
'.hgignore',
'.idea',
'.npmignore',
'.travis.yml',
'LICENSE',
'Thumbs.db',
'docs',
'mkdocs.yml',
'npm-debug.log',
'yarn-debug.log',
'yarn-error.log',
'yarnrc.yml',
'.yarn',
];
const conflicts = fs.readdirSync(root).filter(file => !validFiles.includes(file) &&
// Support IntelliJ IDEA-based editors
!file.endsWith('.iml'));
if (conflicts.length > 0) {
console.log(`The directory ${green(name)} contains files that could conflict:`);
console.log();
for (const file of conflicts) {
try {
const stats = fs.lstatSync(path.join(root, file));
if (stats.isDirectory()) {
console.log(` ${blue(file)}/`);
}
else {
console.log(` ${file}`);
}
}
catch {
console.log(` ${file}`);
}
}
console.log();
console.log('Either try using a new directory name, or remove the files listed above.');
console.log();
return false;
}
return true;
}
//# sourceMappingURL=is-folder-empty.js.map