Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'child_process'
import { execSync, execFileSync } from 'child_process'
import fs from 'fs'
import path from 'path'
import yaml from 'js-yaml'
Expand Down Expand Up @@ -55,7 +55,7 @@ function recFindByExt(base, ext, files, result) {

files.forEach(
function (file) {
var newbase = path.join(base, file)
var newbase = path.join(base, path.basename(file))
if (fs.statSync(newbase).isDirectory()) {
result = recFindByExt(newbase, ext, fs.readdirSync(newbase), result)
} else {
Expand Down Expand Up @@ -83,7 +83,7 @@ function writeOutputToFileByPath(result, srcPath) {

let dartFile = components.join('.').toLowerCase()

var outputFile = outputDir ? path.join(outputDir, dartFile) : dartFile
var outputFile = outputDir ? path.join(outputDir, path.basename(dartFile)) : dartFile
fs.writeFileSync(outputFile, result)
return outputFile
}
Expand Down Expand Up @@ -125,8 +125,7 @@ function postprocessingFiles(filePaths) {
}

function formatDartFile(dartPath) {
var command = 'flutter format ' + dartPath
execSync(command, { stdio: 'inherit' })
execFileSync('flutter', ['format', dartPath], { stdio: 'inherit' })
}

function createFlutterPackage(template, projectName) {
Expand Down Expand Up @@ -262,7 +261,7 @@ export async function main(input, options, onMainThread = false) {
projectName = options.projectName
let template = options.template
if (projectName && checkTemplateValid(template)) {
outputDir = path.join(outputDir, projectName)
outputDir = path.join(outputDir, path.basename(projectName))
createFlutterPackage(template, projectName)
outputDir = path.join(outputDir, 'lib')
}
Expand Down