@@ -20,6 +20,14 @@ const once = (fn, context) => {
2020 } ;
2121} ;
2222
23+ /**
24+ * Checks if a dir has existing files.
25+ * @param {string } path
26+ * @param {string[] } ignore
27+ * @returns {Boolean }
28+ */
29+ const hasExistingFiles = ( path , ignore = [ ] ) => ! ! readdirSync ( path ) . filter ( ( file ) => ! ignore . includes ( file ) ) . length ;
30+
2331/**
2432 * if the input isn't an array, an array will be returned containing the input
2533 * if the input is an array, the input will be returned
@@ -277,8 +285,10 @@ const createThrottledFunction = (fn, time) => {
277285} ;
278286
279287const getTemplates = ( ) => readdirSync ( TEMPLATES_PATH ) . map ( ( name ) => ( { name, path : resolve ( TEMPLATES_PATH , name ) } ) ) ;
280- const copyTemplateByName = ( name , destination ) => copyTemplateByPath ( resolve ( TEMPLATES_PATH , name ) , destination ) ;
281- const copyTemplateByPath = ( path , destination ) => cpSync ( path , destination , { recursive : true } ) ;
288+ const copyTemplateByName = ( name , destination , overwrite ) =>
289+ copyTemplateByPath ( resolve ( TEMPLATES_PATH , name ) , destination , overwrite ) ;
290+ const copyTemplateByPath = ( path , destination , overwrite ) =>
291+ cpSync ( path , destination , { recursive : true , force : overwrite } ) ;
282292
283293/**
284294 * converts {foo:FOO, bar:BAR} to ['foo=FOO', 'bar=BAR']
@@ -380,6 +390,7 @@ const createQueue = () => {
380390 */
381391
382392module . exports = {
393+ hasExistingFiles,
383394 dynamicPromiseAll,
384395 onResolveAll,
385396 objToSerializedEntries,
0 commit comments