egg.js_新建一个egg.js项目(yarn/npm)/简化创建egg项目的脚本/单元测试功能不可用的问题

新建一个egg项目

新建一个目录

执行如下脚本/命令

对于powershell 用户,我编写了如下脚本(powershell 函数)

function EggNew
{
    
    
    param (
        $projectDir = "new_egg_$(date)"
    )
	# 检查目录存在性,以及判空
    if ( Test-Path $DirectoryName)
    {
    
    
        Write-Output "directory already exist,now Set-Location to the directory:$DirectoryName"
        $itemList = Get-ChildItem $DirectoryName
        if ($itemList.count -eq 0)
        {
    
    
            Set-Location $DirectoryName
        }
        else
        {
    
    
            Write-Output "this folder:$DirectoryName is not empty,it is adviced to initial eggProject with a new(or empty) folder.returning..."
            return
        }
    }
    else
    {
    
    
        New-Item -ItemType Directory $DirectoryName
        Set-Location $DirectoryName
    }
    # mkdir $projectDir
	# Set-Location $projectDir
    yarn create egg --type=simple
    yarn install
    ls
}

您可以将该脚本永久化,可以写入powershell的启动配置文件或者模块中

该函数接受一个目录名作为参数,新的项目将建立在该目录下
目前,您需要确保传入的目录名是现在目录中所没有的

单元测试功能不可用?

这与单元测试不通过是两回事,无法启动测试流程可能是node module在安装的时候出错导致,您可以尝试重新执行依赖安装命令:
yarn install
或者
npm install

猜你喜欢

转载自blog.csdn.net/xuchaoxin1375/article/details/121677608