1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-10-30 22:33:11 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

check lockfiles

This commit is contained in:
sunnylqm
2025-04-02 08:27:05 +08:00
parent d351243ab7
commit d281d72737
5 changed files with 14 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ export function addGitIgnore() {
}
if (shouldIgnore.length > 0) {
gitignoreLines.push('# react-native-update');
for (const line of shouldIgnore) {
gitignoreLines.push(line);
console.log(`Added ${line} to .gitignore`);

View File

@@ -1,5 +1,5 @@
import fs from 'node:fs';
import { t } from '../../lib/utils/i18n';
import { t } from './i18n';
const lockFiles = [
'package-lock.json',
@@ -16,9 +16,14 @@ export function checkLockFiles() {
existingLockFiles.push(file);
}
}
if (existingLockFiles.length === 0) {
console.warn(t('lockFilesNotFound'));
} else if (existingLockFiles.length > 1) {
console.warn(t('multipleLockFilesFound'));
if (existingLockFiles.length === 1) {
return;
}
console.warn(t('lockBestPractice'));
if (existingLockFiles.length === 0) {
throw new Error(t('lockNotFound'));
}
throw new Error(
t('multipleLocksFound', { lockFiles: existingLockFiles.join(', ') }),
);
}