File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ async function myPackage() {
1414 // First arg = path
1515 const destPath = path . resolve ( process . argv [ 2 ] ) ;
1616 const projectFolder = utils . normalizeName ( destPath ) ;
17+ const templatePath = path . join ( __dirname , '..' , 'template' ) ;
1718
1819 // TODO Include here a way to get "options" for the other args
1920
@@ -70,15 +71,15 @@ async function myPackage() {
7071 }
7172
7273 // Copy template files
73- utils . copyDirRecursive ( 'template' , destPath ) ;
74+ utils . copyDirRecursive ( templatePath , destPath ) ;
7475
7576 // TODO Copy license and update with project data
7677
7778
7879 // Update readme with project data
7980 let originalReadmeFile ;
8081 try {
81- originalReadmeFile = fs . readFileSync ( './template/ README.md', 'utf8' ) ;
82+ originalReadmeFile = fs . readFileSync ( path . join ( templatePath , ' README.md') , 'utf8' ) ;
8283 } catch ( error ) {
8384 throw error ;
8485 }
@@ -94,7 +95,7 @@ async function myPackage() {
9495 // Update package.json with project data
9596 let originalPackageFile ;
9697 try {
97- originalPackageFile = fs . readFileSync ( './template/ package.json', 'utf8' ) ;
98+ originalPackageFile = fs . readFileSync ( path . join ( templatePath , ' package.json') , 'utf8' ) ;
9899 } catch ( error ) {
99100 throw error ;
100101 }
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ function normalizeName(filepath) {
3232 */
3333function copyDirRecursive ( currentPath = './' , destPath = '../new' ) {
3434 let dest = path . resolve ( destPath ) ;
35+ let current = path . resolve ( currentPath ) ;
3536
3637 // Create the dest folder
3738 if ( ! fs . existsSync ( dest ) ) {
@@ -40,9 +41,9 @@ function copyDirRecursive(currentPath = './', destPath = '../new') {
4041 }
4142
4243 // Read files in folder
43- let files = fs . readdirSync ( currentPath ) ;
44+ let files = fs . readdirSync ( current ) ;
4445 for ( file of files ) {
45- src = path . resolve ( path . join ( currentPath , file ) ) ;
46+ src = path . resolve ( path . join ( current , file ) ) ;
4647 dest = path . resolve ( path . join ( destPath , file ) ) ;
4748
4849 if ( fs . lstatSync ( src ) . isDirectory ( ) ) {
You can’t perform that action at this time.
0 commit comments