-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build: Add temporary user to verdaccio registry
- Loading branch information
1 parent
7dc80d6
commit ba6c56c
Showing
1 changed file
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,13 +119,47 @@ const publish = async (packages: { name: string; location: string }[], url: stri | |
|
||
const addUser = (url: string) => | ||
new Promise<void>(async (res, rej) => { | ||
const username = 'username'; | ||
const password = 'password'; | ||
const email = '[email protected]'; | ||
|
||
logger.log(`👤 add temp user to verdaccio`); | ||
|
||
try { | ||
await execaCommand( | ||
`npx npm-cli-adduser -r ${url} -a -u user -p password -e [email protected]` | ||
); | ||
res(); | ||
const npmExec = execa(`npm add user --registry ${url}`, { shell: true }); | ||
|
||
function checkStep(step: number, count: number) { | ||
if (count > step) { | ||
process.exit(1); | ||
} | ||
} | ||
|
||
let count = 0; | ||
|
||
npmExec.stdout.on('data', (data) => { | ||
const str = data.toString(); | ||
process.stdout.write(str); | ||
if (str.match(/username/i)) { | ||
checkStep(0, count); | ||
process.stdout.write(`${username}\n`); | ||
npmExec.stdin.write(username + '\n'); | ||
} else if (str.match(/password/i)) { | ||
checkStep(1, count); | ||
process.stdout.write('\n'); | ||
npmExec.stdin.write(password + '\n'); | ||
} else if (str.match(/email/i)) { | ||
checkStep(2, count); | ||
process.stdout.write(`${email}\n`); | ||
npmExec.stdin.write(email + '\n'); | ||
npmExec.stdin.end(); | ||
} else if (str.match(/.*err.*/i)) { | ||
npmExec.stdin.end(); | ||
} | ||
count++; | ||
}); | ||
npmExec.on('exit', () => { | ||
res(); | ||
}); | ||
} catch (e) { | ||
rej(e); | ||
} | ||
|