Skip to content

Commit

Permalink
fix: removes nodeModules for lambda functions (#6317)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshbhu committed Jan 5, 2021
1 parent b421058 commit 091e148
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { hashElement } from 'folder-hash';
import glob from 'glob';
import { updateBackendConfigAfterResourceAdd, updateBackendConfigAfterResourceUpdate } from './update-backend-config';
import { JSONUtilities, $TSMeta, pathManager, stateManager } from 'amplify-cli-core';
import { ServiceName } from 'amplify-category-function';

export function updateAwsMetaFile(filePath, category, resourceName, attribute, value, timestamp) {
const amplifyMeta = JSONUtilities.readJson<$TSMeta>(filePath);
Expand Down Expand Up @@ -57,7 +58,9 @@ function moveBackendResourcesToCurrentCloudBackend(resources) {
// in the case that the resource is being deleted, the sourceDir won't exist
if (fs.pathExistsSync(sourceDir)) {
fs.copySync(sourceDir, targetDir);
removeNodeModulesDir(targetDir);
if (resources[i]?.service === ServiceName.LambdaFunction) {
removeNodeModulesDir(targetDir);
}
}
}

Expand All @@ -70,7 +73,7 @@ function moveBackendResourcesToCurrentCloudBackend(resources) {
}
}

function removeNodeModulesDir(currentCloudBackendDir) {
function removeNodeModulesDir(currentCloudBackendDir: string) {
const nodeModulesDirs = glob.sync('**/node_modules', {
cwd: currentCloudBackendDir,
absolute: true,
Expand Down

0 comments on commit 091e148

Please sign in to comment.