Skip to content

Commit

Permalink
Merge pull request #10 from dicoding-dev/improvement/disable-package-…
Browse files Browse the repository at this point in the history
…lock

Improvement/disable package lock
  • Loading branch information
dimasmds authored Oct 3, 2023
2 parents cf6aa0d + 8b88482 commit 48ef8a2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RUN chown -R node:node /app
USER node

COPY --chown=node:node . .
RUN npm config set package-lock false
RUN yarn install --production=true

ENTRYPOINT ["sh", "entrypoint.sh"]
17 changes: 0 additions & 17 deletions src/service/project-preparation/project-preparation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@ import {execSync} from "child_process";
import SubmissionProject from "../../entities/submission-project/submission-project";
import ServerErrorException from "../../exception/server-error-exception";
import raiseDomainEvent from "../../common/domain-event";
import * as fs from "fs";
import {join} from "path";

class ProjectPreparationService {
install(submissionProject: SubmissionProject) {
try {
const isPackageLockExist = fs.existsSync(join(submissionProject.packageJsonPath, 'package-lock.json'))
const isYarnLockExist = fs.existsSync(join(submissionProject.packageJsonPath, 'yarn.lock'))

if (isPackageLockExist) {
execSync('npm ci', {cwd: submissionProject.packageJsonPath, stdio: 'pipe', encoding:'utf-8'})
raiseDomainEvent('dependencies installed')
return
}

if (isYarnLockExist) {
execSync('yarn install --frozen-lockfile', {cwd: submissionProject.packageJsonPath, stdio: 'pipe', encoding:'utf-8'})
raiseDomainEvent('dependencies installed')
return
}

execSync('npm install', {cwd: submissionProject.packageJsonPath, stdio: 'pipe', encoding:'utf-8'})
raiseDomainEvent('dependencies installed')
} catch (e) {
Expand Down

0 comments on commit 48ef8a2

Please sign in to comment.