This commit is contained in:
Timo Hocker 2020-01-17 17:50:10 +01:00
parent e6c447a4b6
commit 8fd02dda35
3 changed files with 45 additions and 9 deletions

View File

@ -12,10 +12,22 @@ const child_process = require ('child_process');
* @param {Array} args function arguments
*/
async function run (folder, args) {
const snip_folder = path.join (folder, args[0]);
const snip_folder_path = [ folder ];
if (args.length > 0)
snip_folder_path.push (args[0]);
const snip_folder = path.join (...snip_folder_path);
const template = path.join (__dirname, 'template');
if (!fs.existsSync (snip_folder))
fs.mkdir (snip_folder);
fs.copy (template, snip_folder);
for (const f of fs.readdirSync (template))
fs.copy (
path.join (template, f),
path.join (snip_folder, f),
{
recursive: true,
filter: (src, dest) => !fs.existsSync (dest)
}
);
child_process.execSync (
'git init',

View File

@ -11,10 +11,22 @@ const path = require ('path');
* @param {Array} args function arguments
*/
function run (folder, args) {
const snip_folder = path.join (folder, args[0]);
const snip_folder_path = [ folder ];
if (args.length > 0)
snip_folder_path.push (args[0]);
const snip_folder = path.join (...snip_folder_path);
const template = path.join (__dirname, 'template');
if (!fs.existsSync (snip_folder))
fs.mkdir (snip_folder);
fs.copy (template, snip_folder);
for (const f of fs.readdirSync (template))
fs.copy (
path.join (template, f),
path.join (snip_folder, f),
{
recursive: true,
filter: (src, dest) => !fs.existsSync (dest)
}
);
}
/**

View File

@ -11,10 +11,22 @@ const path = require ('path');
* @param {Array} args function arguments
*/
function run (folder, args) {
const snip_folder = path.join (folder, args[0]);
const snip_folder_path = [ folder ];
if (args.length > 0)
snip_folder_path.push (args[0]);
const snip_folder = path.join (...snip_folder_path);
const template = path.join (__dirname, 'template');
if (!fs.existsSync (snip_folder))
fs.mkdir (snip_folder);
fs.copy (template, snip_folder);
for (const f of fs.readdirSync (template))
fs.copy (
path.join (template, f),
path.join (snip_folder, f),
{
recursive: true,
filter: (src, dest) => !fs.existsSync (dest)
}
);
}
/**