@@ -12,6 +12,7 @@ import Utils from '../classes/utils.js'
1212import { exec } from '../lib/utils.js'
1313import path from 'node:path'
1414
15+
1516// _dirname
1617const __dirname = path . dirname ( new URL ( import . meta. url ) . pathname )
1718
@@ -36,37 +37,46 @@ export default class Pods extends Command {
3637 */
3738 async run ( ) : Promise < void > {
3839 Utils . titles ( this . id + ' ' + this . argv )
39-
40+
4041 const { args, flags } = await this . parse ( Pods )
4142
4243 if ( process . getuid && process . getuid ( ) === 0 ) {
4344 Utils . warning ( 'You must use eggs pods without sudo' )
4445 process . exit ( 0 )
4546 }
4647
47- // Create pods if not exists
48- const userHome = `/home/ ${ await Utils . getPrimaryUser ( ) } /`
49- if ( ! fs . existsSync ( ` ${ userHome } / pods` ) ) {
50- console . log ( `creating pods folder in ${ userHome } ` )
51- const source = Utils . rootPenguin ( ) + '/pods'
52- await exec ( `cp -r ${ source } ${ userHome } `)
53- }
54-
55- let distro = 'debian'
56- if ( this . argv [ '0' ] !== undefined ) {
57- distro = this . argv [ '0' ]
48+ const userHome = `/home/ ${ await Utils . getPrimaryUser ( ) } /`
49+ if ( ! Utils . isSources ( ) ) {
50+ // Create pods in home, if not exists
51+ if ( ! fs . existsSync ( ` ${ userHome } /pods` ) ) {
52+ if ( await Utils . customConfirm ( ) ) {
53+ console . log ( `Creating pods folder in ${ userHome } `)
54+ await exec ( `cp -r ${ Utils . rootPenguin ( ) } /pods ${ userHome } ` )
55+ } else {
56+ process . exit ( 0 )
57+ }
58+ }
5859 }
5960
6061 let pathPods = path . resolve ( __dirname , `../../pods` )
6162 if ( Utils . rootPenguin ( ) === '/usr/lib/penguins-eggs' ) {
6263 pathPods = path . resolve ( `${ userHome } /pods` )
6364 }
64- let cmd = `${ pathPods } /${ distro } .sh`
6565
66+ let distro = 'debian'
67+ if ( this . argv [ '0' ] !== undefined ) {
68+ distro = this . argv [ '0' ]
69+ }
70+
71+ let cmd = `${ pathPods } /${ distro } .sh`
6672 if ( fs . existsSync ( cmd ) ) {
67- await exec ( cmd )
73+ console . log ( `We are building a egg from a ${ distro } container` )
74+ if ( ! await Utils . customConfirm ( ) ) {
75+ process . exit ( 0 )
76+ }
77+ await exec ( cmd )
6878 } else {
69- console . log ( `script: ${ cmd } not exists ` )
79+ console . log ( `No script: ${ cmd } fpr ${ distro } container ` )
7080 }
7181 }
7282}
0 commit comments