ng generate component pippo
create src/app/pippo/pippo.component.html (24 bytes)
create src/app/pippo/pippo.component.spec.ts (621 bytes)
create src/app/pippo/pippo.component.ts (266 bytes)
create src/app/pippo/pippo.component.scss (0 bytes)
create src/app/components/pippo/tpl/pippo.component.html (24 bytes)
create src/app/components/pippo/ts/pippo.component.spec.ts (621 bytes)
create src/app/components/pippo/ts/pippo.component.ts (266 bytes)
create src/app/components/pippo/scss/pippo.component.scss (0 bytes)
可能吗? 我也可以使用npm“ fs ”
创建自定义任务BAT解决方案
@echo off
setlocal enabledelayedexpansion
ECHO #################################
ECHO #################################
ECHO NG COMPONENT CREATOR BY TONY SAMPERI
ECHO #################################
ECHO #################################
set folderStatus=N
set folderName=newComponent
set sourcePath=%cd%\src\app\components
cd %sourcePath%
echo sourcePath is %sourcePath%
call :getFolderName
IF "!folderStatus!" == "C" call :createStructure
IF "!folderStatus!" == "N" call :failedWarning
PAUSE
endlocal
EXIT /B
:getFolderName
echo Component name?
set /P folderName=
IF exist %folderName% (
echo Directory %folderName% already exists!
goto :getFolderName
) ELSE (
mkdir %folderName%
set folderStatus=C
)
EXIT /B
:createStructure
cd %folderName%
echo Moved to %sourcePath%\%folderName%
mkdir ts
cd ts
type NUL > %folderName%.component.ts
cd ..
mkdir scss
cd scss
type NUL > %folderName%.component.scss
cd ..
mkdir tpl
cd tpl
type NUL > %folderName%.component.html
cd ..
echo DONE.