func deleteFilesNotIncluded()

in cmd/nodejs/firebasebundle/main.go [385:411]


func deleteFilesNotIncluded(apphostingSchema *apphostingYaml, bundleSchema *bundleYaml, appPath string) error {
	// always include apphosting.yaml
	includedFiles := originalApphostingYamlPaths()
	// always include all of .apphosting
	fullyIncludedDirs := []string{".apphosting"}
	if bundleSchema != nil && bundleSchema.OutputFiles.ServerApp.Include != nil {
		includedFiles = append(extractAllDirs(bundleSchema.OutputFiles.ServerApp.Include), includedFiles...)
		fullyIncludedDirs = append(bundleSchema.OutputFiles.ServerApp.Include, fullyIncludedDirs...)
	}
	if apphostingSchema != nil && apphostingSchema.OutputFiles.ServerApp.Include != nil {
		includedFiles = append(extractAllDirs(apphostingSchema.OutputFiles.ServerApp.Include), includedFiles...)
		fullyIncludedDirs = append(apphostingSchema.OutputFiles.ServerApp.Include, fullyIncludedDirs...)
	}
	// if both apphosting.yaml and bundle.yaml are empty, don't delete anything
	if (apphostingSchema == nil || apphostingSchema.OutputFiles.ServerApp.Include == nil) && (bundleSchema == nil || bundleSchema.OutputFiles.ServerApp.Include == nil) {
		return nil
	}
	// Check if "." is present in either include list
	for _, dir := range fullyIncludedDirs {
		if dir == "." {
			// If "." is present, don't delete anything
			return nil
		}
	}

	return walkDirStructureAndDeleteAllFilesNotIncluded(appPath, includedFiles, fullyIncludedDirs)
}