-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create-app - take app directory as argument (#1674)
- Loading branch information
Showing
5 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
const Fs = require("opfs"); | ||
const Path = require("path"); | ||
|
||
async function prepareAppDir() { | ||
const appDirName = process.argv[2]; | ||
if (!appDirName) { | ||
console.log(` | ||
Usage: @xarc/create-app <app-directory> | ||
- pass '.' to use current directory | ||
`); | ||
process.exit(1); | ||
} | ||
|
||
if (appDirName === ".") { | ||
const dirName = Path.basename(process.cwd()); | ||
console.log(`Using current directory '${dirName}' to create @xarc/app`); | ||
return dirName; | ||
} | ||
|
||
try { | ||
await Fs.mkdir(appDirName); | ||
} catch (err) { | ||
if (err.code !== "EEXIST") { | ||
console.log(`Failed to create app directory '${appDirName}'`); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
process.chdir(appDirName); | ||
|
||
return appDirName; | ||
} | ||
|
||
module.exports = prepareAppDir; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters