@sakilalakmal/common 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -0
- package/publish.js +36 -0
package/package.json
ADDED
package/publish.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const readline = require('readline');
|
|
3
|
+
|
|
4
|
+
const rl = readline.createInterface({
|
|
5
|
+
input: process.stdin,
|
|
6
|
+
output: process.stdout
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
rl.question('Please enter your npm OTP code: ', (otp) => {
|
|
10
|
+
if (!otp) {
|
|
11
|
+
console.error('OTP code is required.');
|
|
12
|
+
rl.close();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Use JSON.stringify to safely handle the package name
|
|
17
|
+
const packageName = JSON.parse(require('fs').readFileSync('package.json', 'utf8')).name;
|
|
18
|
+
const publishCommand = `npm publish --otp=${otp}`;
|
|
19
|
+
|
|
20
|
+
console.log(`Running: ${publishCommand}`);
|
|
21
|
+
|
|
22
|
+
const child = exec(publishCommand, { cwd: __dirname });
|
|
23
|
+
|
|
24
|
+
child.stdout.on('data', (data) => {
|
|
25
|
+
console.log(data);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.stderr.on('data', (data) => {
|
|
29
|
+
console.error(data);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on('close', (code) => {
|
|
33
|
+
console.log(`npm publish process exited with code ${code}`);
|
|
34
|
+
rl.close();
|
|
35
|
+
});
|
|
36
|
+
});
|