Skip to content

Commit

Permalink
Merge pull request #18 from getcronit/fix/include-gitignore
Browse files Browse the repository at this point in the history
fix: include template .gitignore in pylon creation
  • Loading branch information
schettn authored Sep 24, 2024
2 parents 0369e85 + 9c3247f commit a23fbb3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/create-pylon/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const createTemplate = async (options: {
// Copy the shared template files
readdirFilesSyncRecursive(sharedTemplateDir).forEach(file => {
const source = path.join(sharedTemplateDir, file)
const target = path.join(targetDirectoryPath, file)
let target = path.join(targetDirectoryPath, file)

// Create folder recursively and copy file

Expand All @@ -178,6 +178,13 @@ const createTemplate = async (options: {
fs.mkdirSync(targetDir, {recursive: true})
}

// If the target ends with `.example`, remove the suffix.
// This is useful for `.gitignore.example` files because they are not published in
// the `create-pylon` package when named `.gitignore`.
if (target.endsWith('.example')) {
target = target.replace('.example', '')
}

const injectedContent = inject(fs.readFileSync(source, 'utf-8'))

fs.writeFileSync(target, injectedContent)
Expand All @@ -186,7 +193,7 @@ const createTemplate = async (options: {
// Copy the runtime specific template files
readdirFilesSyncRecursive(templateDir).forEach(file => {
const source = path.join(templateDir, file)
const target = path.join(targetDirectoryPath, file)
let target = path.join(targetDirectoryPath, file)

// Create folder recursively and copy file
const targetDir = path.dirname(target)
Expand All @@ -195,6 +202,13 @@ const createTemplate = async (options: {
fs.mkdirSync(targetDir, {recursive: true})
}

// If the target ends with `.example`, remove the suffix.
// This is useful for `.gitignore.example` files because they are not published in
// the `create-pylon` package when named `.gitignore`.
if (target.endsWith('.example')) {
target = target.replace('.example', '')
}

const injectedContent = inject(fs.readFileSync(source, 'utf-8'))

fs.writeFileSync(target, injectedContent)
Expand Down

0 comments on commit a23fbb3

Please sign in to comment.