Skip to content

Commit

Permalink
update package installation tips for install (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhe123 authored Nov 15, 2019
1 parent 02f2875 commit e726ee1
Show file tree
Hide file tree
Showing 5 changed files with 3,352 additions and 114 deletions.
2 changes: 1 addition & 1 deletion bin/fun-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ program
.option('-e, --env <env>', 'environment variable, ex. -e PATH=/code/bin', (e, envs) => (envs.push(e), envs), [])
.option('-d, --use-docker', 'Use docker container to install function dependencies')
.option('--save', 'add task to fun.yml file.')
.option('-p, --package-type <type>', 'avaliable package type option: pip, apt.')
.option('-p, --package-type <type>', 'avaliable package type option: pip, apt, npm.')
.arguments('[packageNames...]')
.description('install dependencies which are described in fun.yml file.')
.action(async (packageNames, program) => {
Expand Down
1 change: 1 addition & 0 deletions lib/build/build-opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function generateBuildContainerBuildOpts(serviceName, serviceRes, function
sourceDir: '/code',
runtime,
artifactDir: codeUri === funcArtifactDir ? '/code' : funcArtifactMountDir,
stages,
verbose
};

Expand Down
1 change: 0 additions & 1 deletion lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ async function startSboxContainer({
stream.write(' \b');
}


await container.wait();

// cleanup
Expand Down
36 changes: 20 additions & 16 deletions lib/fc-error-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ class ErrorProcessor {
match(message) { }
async process(message) { }
async postProcess() {
console.log(red('\nFun will auto exit after 3 seconds.\n'));

if (!detectMocha()) {
unrefTimeout(() => {
process.emit('SIGINT');
}, 3000);
}
process.nextTick(() => {
console.log(red('\nFun will auto exit after 3 seconds.\n'));

if (!detectMocha()) {
unrefTimeout(() => {
process.emit('SIGINT');
}, 3000);
}
});
}
}

Expand Down Expand Up @@ -98,25 +100,27 @@ class DynamicLinkLibraryMissingProcessor extends ErrorProcessor {
process.nextTick(() => {
console.log(red(`Tips: Fun has detected that you are missing ${lib} library, you can try to install it like this:
1. fun install sbox -f ${this.serviceName}/${this.functionName} -i
2. fun-install apt-get install ${packageName}
3. type 'exit' to exit container and then reRun your function
step1: fun install sbox -f ${this.serviceName}/${this.functionName} -i
step2: fun-install apt-get install ${packageName}
step3: type 'exit' to exit container and then reRun your function
Also you can install dependencies through one command:
fun install sbox -f puppeteer/html2png --cmd 'fun-install apt-get install ${packageName}'
fun install sbox -f puppeteer/html2png --cmd 'fun-install apt-get install ${packageName}'
`));
});
} else {
console.log(red(`Tips: Fun has detected that you are missing ${lib} library, you can try to install it like this:
1. open this page ${this.debianPakcageUrlPrefix}${lib} to find your missing dependency
2. fun install sbox -f ${this.serviceName}/${this.functionName} -i
3. fun-install apt-get install YourPackageName
4. type 'exit' to exit container and then reRun your function
step1: open this page ${this.debianPakcageUrlPrefix}${lib} to find your missing dependency
step2: fun install sbox -f ${this.serviceName}/${this.functionName} -i
step3: fun-install apt-get install YourPackageName
step4: type 'exit' to exit container and then reRun your function
Also you can install dependencies through one command:
fun install sbox -f puppeteer/html2png --cmd 'fun-install apt-get install YourPackageName'
fun install sbox -f puppeteer/html2png --cmd 'fun-install apt-get install YourPackageName'
`));
}
}
Expand Down
Loading

0 comments on commit e726ee1

Please sign in to comment.