Skip to content

Commit

Permalink
copy folder with pkg compat
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeseda committed Apr 9, 2024
1 parent 5529ece commit ce48d99
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/binary-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ jobs:
# Test the build
build:
# Setup
runs-on: ubuntu-latest
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ windows-latest, ubuntu-latest, macOS-latest, self-hosted ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, macOS-latest, self-hosted ]

# Go
steps:
Expand Down
29 changes: 25 additions & 4 deletions src/commands/new/action.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = async function (params) {
let { cpSync, existsSync, mkdirSync, readFileSync } = require('fs')
let { lstatSync, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync } = require('fs')
let { isAbsolute, join, normalize } = require('path')

let { args } = params
Expand Down Expand Up @@ -31,7 +31,7 @@ module.exports = async function (params) {
}

// App name (optional)
let appName = args.name || args.n ? args.name || args.n : 'begin-app'
let appName = args.name || args.n ? args.name || args.n : 'begin-app'
if (!looseName.test(appName)) {
return error('invalid_appname')
}
Expand Down Expand Up @@ -62,9 +62,30 @@ module.exports = async function (params) {
// Starter project files
let appPath = join(nodeModules, '@enhance', 'starter-project', 'app')
let publicPath = join(nodeModules, '@enhance', 'starter-project', 'public')

/* pkg workaround */
function copyFolderSync (from, to) {
mkdirSync(to)
readdirSync(from).forEach(element => {
const sourcePath = join(from, element)
const destinationPath = join(to, element)
if (lstatSync(sourcePath).isFile()) {
copyFileSync(sourcePath, destinationPath)
}
else {
copyFolderSync(sourcePath, destinationPath)
}
})
}

// Copy app dirs
cpSync(appPath, p('app'), { recursive: true })
cpSync(publicPath, p('public'), { recursive: true })
copyFolderSync(appPath, p('app'))
copyFolderSync(publicPath, p('public'))
/* end pkg workaround */

// Use this when pkg is no longer used:
// fs.cpSync(appPath, p('app'), { recursive: true })
// fs.cpSync(publicPath, p('public'), { recursive: true })

// Write .gitignore
let gitIgnoreTemplate = join(nodeModules, '@enhance', 'starter-project', 'template.gitignore')
Expand Down

0 comments on commit ce48d99

Please sign in to comment.