From dabd56143b1eba2c29ac19458fea1c9854cb57ae Mon Sep 17 00:00:00 2001 From: Eric McCormick Date: Mon, 29 Oct 2018 22:42:24 -0500 Subject: [PATCH 1/3] makes tar extraction depth configurable defaults to 3 for consistency, but makes template depth (in repo) configurable 1 is root of project repo, as the case may be --- index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 43bc9e2..435866e 100644 --- a/index.js +++ b/index.js @@ -30,10 +30,11 @@ const getTar = ({ user, repo, path = '', - name + name, + depth = 3 }) => { const url = `https://codeload.github.com/${user}/${repo}/tar.gz/master` - const cmd = `curl ${url} | tar -xz -C ${name} --strip=3 ${repo}-master/${path}` + const cmd = `curl ${url} | tar -xz -C ${name} --strip=${depth} ${repo}-master/${path}` exec(cmd, { stdio: 'inherit' }) } @@ -51,6 +52,7 @@ const create = async (opts = {}) => { const dirname = path.resolve(opts.name) const name = path.basename(dirname) const [ user, repo, ...paths ] = opts.template.split('/') + const depth = opts.templateDepth fs.ensureDirSync(name) @@ -58,7 +60,8 @@ const create = async (opts = {}) => { name, user, repo, - path: paths.join('/') + path: paths.join('/'), + depth })) const templatePkg = require( From 4cda4dba28dca4c9fd7f0aab23f18d2338be3f52 Mon Sep 17 00:00:00 2001 From: Eric McCormick Date: Thu, 6 Jun 2019 22:12:36 -0500 Subject: [PATCH 2/3] updates tar extraction depth drive off of paths.length --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 435866e..17f14cc 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ const getTar = ({ repo, path = '', name, - depth = 3 + depth }) => { const url = `https://codeload.github.com/${user}/${repo}/tar.gz/master` const cmd = `curl ${url} | tar -xz -C ${name} --strip=${depth} ${repo}-master/${path}` @@ -52,7 +52,7 @@ const create = async (opts = {}) => { const dirname = path.resolve(opts.name) const name = path.basename(dirname) const [ user, repo, ...paths ] = opts.template.split('/') - const depth = opts.templateDepth + const depth = paths.length+1 fs.ensureDirSync(name) From 2229654c1773d00216f095b35514b5d43380ad84 Mon Sep 17 00:00:00 2001 From: Eric McCormick Date: Mon, 25 Jan 2021 09:14:26 -0600 Subject: [PATCH 3/3] ensures default value for depth (defaulting to 3 for consistency) --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 17f14cc..60f5d55 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ const getTar = ({ repo, path = '', name, - depth + depth = 3 }) => { const url = `https://codeload.github.com/${user}/${repo}/tar.gz/master` const cmd = `curl ${url} | tar -xz -C ${name} --strip=${depth} ${repo}-master/${path}`