Skip to content

Commit d351243

Browse files
committed
check lockfile
1 parent fbdacff commit d351243

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

src/bundle.ts

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const properties = require('properties');
1313
import { depVersions } from './utils/dep-versions';
1414
import { t } from './utils/i18n';
1515
import { tempDir } from './utils/constants';
16+
import { checkLockFiles } from './utils/check-lockfile';
17+
import { addGitIgnore } from './utils/add-gitignore';
1618

1719
let bsdiff;
1820
let hdiff;
@@ -913,6 +915,9 @@ export const commands = {
913915
platform,
914916
});
915917

918+
checkLockFiles();
919+
addGitIgnore();
920+
916921
const bundleParams = await checkPlugins();
917922
const sourcemapPlugin = bundleParams.sourcemap;
918923
const isSentry = bundleParams.sentry;

src/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import updateNotifier from 'update-notifier';
55
import { printVersionCommand } from './utils';
66
import pkg from '../package.json';
77
import { t } from './utils/i18n';
8-
import { addGitIgnore } from './utils/add-gitignore';
98

109
updateNotifier({ pkg }).notify({
1110
isGlobal: true,
@@ -33,7 +32,6 @@ const commands = {
3332
};
3433

3534
async function run() {
36-
addGitIgnore();
3735
await printVersionCommand();
3836
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
3937
process.exit();

src/utils/add-gitignore.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import fs from 'node:fs';
2-
import path from 'node:path';
2+
// import path from 'node:path';
33
import { credentialFile, tempDir } from './constants';
44

55
export function addGitIgnore() {
66
const shouldIgnore = [credentialFile, tempDir];
77

8-
const gitignorePath = path.join(process.cwd(), '.gitignore');
8+
const gitignorePath = '.gitignore';
99

1010
if (!fs.existsSync(gitignorePath)) {
1111
return;
@@ -16,7 +16,7 @@ export function addGitIgnore() {
1616
const gitignoreLines = gitignoreContent.split('\n');
1717

1818
for (const line of gitignoreLines) {
19-
const index = shouldIgnore.indexOf(line);
19+
const index = shouldIgnore.indexOf(line.trim());
2020
if (index !== -1) {
2121
shouldIgnore.splice(index, 1);
2222
}

src/utils/check-lockfile.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import fs from 'node:fs';
2+
import { t } from '../../lib/utils/i18n';
3+
4+
const lockFiles = [
5+
'package-lock.json',
6+
'yarn.lock',
7+
'pnpm-lock.yaml',
8+
'bun.lockb',
9+
'bun.lock',
10+
];
11+
12+
const existingLockFiles: string[] = [];
13+
export function checkLockFiles() {
14+
for (const file of lockFiles) {
15+
if (fs.existsSync(file)) {
16+
existingLockFiles.push(file);
17+
}
18+
}
19+
if (existingLockFiles.length === 0) {
20+
console.warn(t('lockFilesNotFound'));
21+
} else if (existingLockFiles.length > 1) {
22+
console.warn(t('multipleLockFilesFound'));
23+
}
24+
}

src/utils/lock-checker.ts

-7
This file was deleted.

0 commit comments

Comments
 (0)