import * as fse from 'fs-extra' ; import * as path from 'path' ; import { DebugConfiguration , TaskDefinition } from "vscode" ; import { extInstallTaskName , func , hostStartCommand , ProjectLanguage } from "../../../constants" ; import { nodeDebugConfig } from "../../../debug/NodeDebugProvider" ; import { getFuncWatchProblemMatcher } from '../../../vsCodeConfig/settings' ; import { convertToFunctionsTaskLabel } from '../../../vsCodeConfig/tasks' ; import { IProjectWizardContext } from "../../createNewProject/IProjectWizardContext" ; import { ScriptInitVSCodeStep } from './ScriptInitVSCodeStep' ; const npmInstallTaskLabel = convertToFunctionsTaskLabel ( 'npm install' ) ; const npmPruneTaskLabel = convertToFunctionsTaskLabel ( 'npm prune' ) ; export class JavaScriptInitVSCodeStep extends ScriptInitVSCodeStep { private hasPackageJson : boolean ; protected async executeCore ( context ) { await super . executeCore ( context ) ; this . hasPackageJson = await fse . pathExists ( path . join ( context . projectPath , 'package.json' ) ) ; if ( this . hasPackageJson ) { this . preDeployTask = npmPruneTaskLabel ; this . settings . push ( { key : 'postDeployTask' , value : npmInstallTaskLabel } ) ; } } protected getDebugConfiguration ( ) { return nodeDebugConfig ; } protected getTasks ( language ) { if ( ! this . hasPackageJson ) { return super . getTasks ( language ) ; } else { return [ { type : func , command : hostStartCommand , problemMatcher : getFuncWatchProblemMatcher ( language ) , isBackground : true , dependsOn : this . useFuncExtensionsInstall ? [ extInstallTaskName , npmInstallTaskLabel ] : npmInstallTaskLabel } , { type : 'shell' , label : npmInstallTaskLabel , command : 'npm install' } , { type : 'shell' , label : npmPruneTaskLabel , command : 'npm prune --production' , dependsOn : this . useFuncExtensionsInstall ? extInstallTaskName : undefined , problemMatcher : [ ] } ] ; } } }