Skip to content

Commit 3a4d579

Browse files
committed
feedback
1 parent 98d7fe6 commit 3a4d579

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

build/esbuild/build.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function style({
141141
onLoad({ filter: /.*/, namespace: 'style-content' }, async (args) => {
142142
// Process with PostCSS/Tailwind if enabled and file exists
143143
if (enableTailwind && args.path.includes('tailwind.css') && fs.existsSync(args.path)) {
144-
try {
144+
try {
145145
const cssContent = await fs.readFile(args.path, 'utf8');
146146
const result = await postcss([tailwindcss, autoprefixer]).process(cssContent, {
147147
from: args.path,
@@ -158,13 +158,11 @@ function style({
158158
});
159159
const { errors, warnings, outputFiles } = await esbuild.build(options);
160160
return { errors, warnings, contents: outputFiles![0].text, loader: 'text' };
161-
} catch (error) {
162-
console.error(`PostCSS processing failed for ${args.path}:`, error);
163-
throw error;
164-
}
161+
} catch (error) {
162+
console.error(`PostCSS processing failed for ${args.path}:`, error);
163+
throw error;
164+
}
165165
}
166-
// …rest of the onLoad handler…
167-
});
168166

169167
// Default behavior for other CSS files
170168
const options = { entryPoints: [args.path], ...opt };
@@ -175,7 +173,9 @@ function style({
175173
options.loader[key] = loader[key];
176174
}
177175
});
176+
178177
const { errors, warnings, outputFiles } = await esbuild.build(options);
178+
179179
return { errors, warnings, contents: outputFiles![0].text, loader: 'text' };
180180
});
181181
}

src/notebooks/deepnote/deepnoteRequirementsHelper.node.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ export class DeepnoteRequirementsHelper implements IDeepnoteRequirementsHelper {
4141
return;
4242
}
4343

44-
// Validate and normalize requirements: ensure they are valid strings, trim them, and remove empty entries
45-
const normalizedRequirements = requirements
46-
.filter((req) => typeof req === 'string') // Keep only string entries
47-
.map((req) => req.trim()) // Trim whitespace
48-
.filter((req) => req.length > 0); // Remove empty strings
44+
// Validate and normalize requirements: ensure they are valid strings, trim them, remove empty entries, and dedupe
45+
const normalizedRequirements = Array.from(
46+
new Set(
47+
requirements
48+
.filter((req): req is string => typeof req === 'string') // Keep only string entries with type guard
49+
.map((req) => req.trim()) // Trim whitespace
50+
.filter((req) => req.length > 0) // Remove empty strings
51+
)
52+
);
4953

5054
if (normalizedRequirements.length === 0) {
5155
this.logger.info(`No valid requirements found in project ${project.project.id}`);
@@ -67,20 +71,25 @@ export class DeepnoteRequirementsHelper implements IDeepnoteRequirementsHelper {
6771
// Use Uri.joinPath to build the filesystem path using the Uri API
6872
const requirementsPath = Uri.joinPath(workspaceFolders[0].uri, 'requirements.txt').fsPath;
6973

70-
// Convert normalized requirements array to text format
74+
// Convert normalized requirements array to text format (using LF line endings)
7175
const requirementsText = normalizedRequirements.join('\n') + '\n';
7276

77+
// Helper to normalize line endings to LF for comparison
78+
const normalizeLineEndings = (text: string): string => text.replace(/\r\n/g, '\n');
79+
7380
// Check if requirements.txt already exists
7481
const fileExists = await fs.promises
7582
.access(requirementsPath)
7683
.then(() => true)
7784
.catch(() => false);
7885

7986
if (fileExists) {
80-
// Read existing file contents and compare
87+
// Read existing file contents and compare (normalize line endings for comparison)
8188
const existingContent = await fs.promises.readFile(requirementsPath, 'utf8');
89+
const normalizedExistingContent = normalizeLineEndings(existingContent);
90+
const normalizedRequirementsText = normalizeLineEndings(requirementsText);
8291

83-
if (existingContent === requirementsText) {
92+
if (normalizedExistingContent === normalizedRequirementsText) {
8493
this.logger.info('requirements.txt already has the correct content, skipping update');
8594
return;
8695
}

src/webviews/extension-side/dataframe/dataframeController.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { injectable } from 'inversify';
22
import {
33
commands,
44
env,
5+
l10n,
56
NotebookEdit,
67
NotebookEditor,
78
NotebookRendererMessaging,
@@ -86,9 +87,9 @@ export class DataframeController implements IExtensionSyncActivationService {
8687

8788
private async handleSelectPageSize(editor: NotebookEditor, message: SelectPageSizeCommand) {
8889
if (!message.cellId && message.cellIndex === undefined) {
89-
const errorMessage =
90-
'Unable to update page size: No cell identifier provided. ' +
91-
'Please re-run the cell to update the output metadata.';
90+
const errorMessage = l10n.t(
91+
'Unable to update page size: No cell identifier provided. Please re-run the cell to update the output metadata.'
92+
);
9293

9394
logger.error(`[DataframeController] ${errorMessage}`);
9495

@@ -101,7 +102,10 @@ export class DataframeController implements IExtensionSyncActivationService {
101102
const cell = cells.find((c) => c.metadata.id === message.cellId);
102103

103104
if (!cell) {
104-
const errorMessage = `Unable to update page size: Could not find the cell with ID ${message.cellId}. The cell may have been deleted.`;
105+
const errorMessage = l10n.t(
106+
'Unable to update page size: Could not find the cell with ID {0}. The cell may have been deleted.',
107+
message.cellId ?? ''
108+
);
105109

106110
logger.error(`[DataframeController] ${errorMessage}`);
107111

@@ -140,9 +144,9 @@ export class DataframeController implements IExtensionSyncActivationService {
140144

141145
private async handleGoToPage(editor: NotebookEditor, message: GoToPageCommand) {
142146
if (!message.cellId) {
143-
const errorMessage =
144-
'Unable to navigate to page: No cell identifier provided. ' +
145-
'Please re-run the cell to update the output metadata.';
147+
const errorMessage = l10n.t(
148+
'Unable to navigate to page: No cell identifier provided. Please re-run the cell to update the output metadata.'
149+
);
146150

147151
logger.error(`[DataframeController] ${errorMessage}`);
148152

@@ -155,7 +159,10 @@ export class DataframeController implements IExtensionSyncActivationService {
155159
const cell = cells.find((c) => c.metadata.id === message.cellId);
156160

157161
if (!cell) {
158-
const errorMessage = `Unable to navigate to page: Could not find the cell with ID ${message.cellId}. The cell may have been deleted.`;
162+
const errorMessage = l10n.t(
163+
'Unable to navigate to page: Could not find the cell with ID {0}. The cell may have been deleted.',
164+
message.cellId ?? ''
165+
);
159166

160167
logger.error(`[DataframeController] ${errorMessage}`);
161168

0 commit comments

Comments
 (0)