Skip to content

Commit

Permalink
Merge pull request #8 from dicoding-dev/improvement/remove-lock-support
Browse files Browse the repository at this point in the history
Improvement/remove lock support after given write permission by grader runner
  • Loading branch information
dimasmds authored Sep 28, 2023
2 parents ceaa226 + 0911712 commit 1bbd46f
Showing 1 changed file with 0 additions and 17 deletions.
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 1bbd46f

Please sign in to comment.