Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa9b10d

Browse filesBrowse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
fix: copy example with .pde main sketch file
Closes #2377 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 4217c00 commit aa9b10d
Copy full SHA for aa9b10d

File tree

2 files changed

+40
-4
lines changed
Filter options

2 files changed

+40
-4
lines changed

‎arduino-ide-extension/src/node/sketches-service-impl.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/node/sketches-service-impl.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,13 @@ export class SketchesServiceImpl
609609
force: true,
610610
});
611611

612+
const sourceMainSketchFilePath = FileUri.fsPath(sketch.mainFileUri);
613+
// Can copy sketch with pde main sketch file: https://github.com/arduino/arduino-ide/issues/2377
614+
const ext = path.extname(sourceMainSketchFilePath);
615+
612616
// rename the main sketch file
613617
await fs.rename(
614-
join(temp, `${sourceFolderBasename}.ino`),
618+
join(temp, `${sourceFolderBasename}${ext}`),
615619
join(temp, `${destinationFolderBasename}.ino`)
616620
);
617621

‎arduino-ide-extension/src/test/node/sketches-service-impl.slow-test.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/test/node/sketches-service-impl.slow-test.ts
+35-3Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ import {
33
DisposableCollection,
44
} from '@theia/core/lib/common/disposable';
55
import { isWindows } from '@theia/core/lib/common/os';
6+
import { URI } from '@theia/core/lib/common/uri';
67
import { FileUri } from '@theia/core/lib/node/file-uri';
78
import { Container } from '@theia/core/shared/inversify';
89
import { expect } from 'chai';
9-
import { promises as fs } from 'node:fs';
10-
import { basename, join } from 'node:path';
1110
import { rejects } from 'node:assert/strict';
11+
import { promises as fs } from 'node:fs';
12+
import path, { basename, join } from 'node:path';
1213
import { sync as rimrafSync } from 'rimraf';
1314
import temp from 'temp';
1415
import { Sketch, SketchesError, SketchesService } from '../../common/protocol';
1516
import {
16-
isAccessibleSketchPath,
1717
SketchesServiceImpl,
18+
isAccessibleSketchPath,
1819
} from '../../node/sketches-service-impl';
1920
import { ErrnoException } from '../../node/utils/errors';
2021
import { createBaseContainer, startDaemon } from './node-test-bindings';
@@ -332,6 +333,37 @@ describe('sketches-service-impl', () => {
332333
);
333334
});
334335

336+
it('should copy sketch if the main sketch file has pde extension (#2377)', async () => {
337+
const sketchesService =
338+
container.get<SketchesServiceImpl>(SketchesService);
339+
let sketch = await sketchesService.createNewSketch();
340+
toDispose.push(disposeSketch(sketch));
341+
expect(sketch.mainFileUri.endsWith('.ino')).to.be.true;
342+
343+
// Create a sketch and rename the main sketch file to .pde
344+
const mainSketchFilePathIno = FileUri.fsPath(new URI(sketch.mainFileUri));
345+
const sketchFolderPath = path.dirname(mainSketchFilePathIno);
346+
const mainSketchFilePathPde = path.join(
347+
sketchFolderPath,
348+
`${basename(sketchFolderPath)}.pde`
349+
);
350+
await fs.rename(mainSketchFilePathIno, mainSketchFilePathPde);
351+
352+
sketch = await sketchesService.loadSketch(sketch.uri);
353+
expect(sketch.mainFileUri.endsWith('.pde')).to.be.true;
354+
355+
const tempDirPath = await sketchesService['createTempFolder']();
356+
const destinationPath = join(tempDirPath, 'GH-2377');
357+
const destinationUri = FileUri.create(destinationPath).toString();
358+
359+
await sketchesService.copy(sketch, {
360+
destinationUri,
361+
});
362+
363+
const copiedSketch = await sketchesService.loadSketch(destinationUri);
364+
expect(copiedSketch.mainFileUri.endsWith('.ino')).to.be.true;
365+
});
366+
335367
it('should copy sketch inside the sketch folder', async () => {
336368
const sketchesService =
337369
container.get<SketchesServiceImpl>(SketchesService);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.