Skip to content

Commit

Permalink
chore(serverless#281): cleanup commented out code, remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
John Reeves committed Oct 27, 2022
1 parent 953c437 commit 70dd1d6
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class TypeScriptPlugin {

if (!this.originalServicePath) {
// Save original service path and functions
// console.error('HEYO! ' + JSON.stringify({v: this.serverless['version'], serverlessPath: this.serverless.config['serverlessPath'], serviceDir: this.serverless.config['serviceDir'], slsServiceDir: this.serverless['serviceDir'], top: Object.keys(this.serverless), conf: Object.keys(this.serverless.config)}))
this.originalServicePath = this.getServicePath()
// Fake service path so that serverless will know what to zip
this.setServicePath(path.join(this.originalServicePath, BUILD_FOLDER))
Expand All @@ -190,8 +189,6 @@ export class TypeScriptPlugin {

const emitedFiles = await typescript.run(this.rootFileNames, tsconfig)
this.serverless.cli.log('Typescript compiled.')
// this.setServicePath(this.originalServicePath)
// this.originalServicePath = null
return emitedFiles
}

Expand All @@ -201,7 +198,6 @@ export class TypeScriptPlugin {

private getServicePath(): string {
const path = this.serverless.config.servicePath || this.serverless.config.serviceDir
// const path = 'servicePath' in this.serverless.config ? this.serverless.config.servicePath : this.serverless.config.serviceDir
if (!path) {
throw new Error('Could not find serverless serviceDir or servicePath')
}
Expand All @@ -211,12 +207,6 @@ export class TypeScriptPlugin {
private setServicePath(value: string) {
this.serverless.config.serviceDir = value
this.serverless.config.servicePath = value
// if ('serviceDir' in this.serverless.config) {
// // serverless V3 config
// }
// else {
// // Serverless <V3 config
// }
}

/**
Expand All @@ -228,7 +218,6 @@ export class TypeScriptPlugin {
const { service } = this.serverless

const patterns = [...(service.package.include || []), ...(service.package.patterns || [])]
this.serverless.cli.log(`TS: copyExtras: ${JSON.stringify(patterns)}`)
// include any "extras" from the "include" section
if (patterns.length > 0) {
const files = await globby(patterns)
Expand All @@ -254,7 +243,6 @@ export class TypeScriptPlugin {
* @param isPackaging Provided if serverless is packaging the service for deployment
*/
async copyDependencies(isPackaging = false) {
this.serverless.cli.log('TS: copyDependencies')
const outPkgPath = path.resolve(path.join(BUILD_FOLDER, 'package.json'))
const outModulesPath = path.resolve(path.join(BUILD_FOLDER, 'node_modules'))

Expand Down Expand Up @@ -288,7 +276,6 @@ export class TypeScriptPlugin {
path.join(this.getRealServicePath(), BUILD_FOLDER, SERVERLESS_FOLDER),
path.basename(oldHome)
)
this.serverless.cli.log(`TS: copying ${oldHome} to ${newHome}`)
await fs.copy(oldHome, newHome)
functionObject.package.artifact = newHome
}
Expand All @@ -302,12 +289,10 @@ export class TypeScriptPlugin {
async moveArtifacts(): Promise<void> {
const { service } = this.serverless

this.serverless.cli.log('TS: moveArtifacts .serverless')
await fs.copy(
path.join(this.getRealServicePath(), BUILD_FOLDER, SERVERLESS_FOLDER),
path.join(this.getRealServicePath(), SERVERLESS_FOLDER)
)
this.serverless.cli.log('TS: post-copy')

const layerNames = service.getAllLayers()
layerNames.forEach(name => {
Expand All @@ -316,7 +301,6 @@ export class TypeScriptPlugin {
SERVERLESS_FOLDER,
path.basename(service.layers[name].package.artifact)
)
this.serverless.cli.log('TS: ' + name + ' ' + service.layers[name].package.artifact)
})

if (this.options.function) {
Expand All @@ -338,7 +322,6 @@ export class TypeScriptPlugin {
SERVERLESS_FOLDER,
path.basename(service.functions[name].package.artifact)
)
this.serverless.cli.log(`TS: ${name} - ${service.functions[name].package.artifact}`)
})
return
}
Expand All @@ -348,11 +331,9 @@ export class TypeScriptPlugin {
SERVERLESS_FOLDER,
path.basename(service.package.artifact)
)
this.serverless.cli.log(`TS: service.package.artifact: ${service.package.artifact}`)
}

async cleanup(): Promise<void> {
this.serverless.cli.log('TS: cleanup')
await this.moveArtifacts()
// Restore service path
this.setServicePath(this.originalServicePath)
Expand Down

0 comments on commit 70dd1d6

Please sign in to comment.