device-shots 0.4.0 → 0.4.1
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/dist/index.js +20 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
existsSync as existsSync4,
|
|
12
12
|
mkdirSync,
|
|
13
13
|
readdirSync as readdirSync2,
|
|
14
|
-
|
|
14
|
+
copyFileSync,
|
|
15
|
+
unlinkSync,
|
|
15
16
|
readFileSync,
|
|
16
17
|
writeFileSync
|
|
17
18
|
} from "fs";
|
|
@@ -705,7 +706,7 @@ Detected ${devices.length} device(s) with ${bundleIdDisplay}:`)
|
|
|
705
706
|
const captured = [];
|
|
706
707
|
for (const device of devices) {
|
|
707
708
|
const filename = `${screenshotName}.png`;
|
|
708
|
-
const tmpPath = join4(tmpDir, `${device.platform}_${device.screenSize}_${filename}`);
|
|
709
|
+
const tmpPath = join4(tmpDir, `${device.platform}_${device.screenSize}_${device.safeName}_${filename}`);
|
|
709
710
|
const icon = device.platform === "ios" ? "iOS" : "Android";
|
|
710
711
|
const s = ora(
|
|
711
712
|
`${icon}: Capturing from ${device.displayName}...`
|
|
@@ -737,10 +738,25 @@ Detected ${devices.length} device(s) with ${bundleIdDisplay}:`)
|
|
|
737
738
|
s.fail(`${icon}: Failed to capture from ${device.displayName}`);
|
|
738
739
|
}
|
|
739
740
|
}
|
|
741
|
+
const movedBuckets = /* @__PURE__ */ new Set();
|
|
740
742
|
for (const file of captured) {
|
|
743
|
+
const bucketKey = `${file.platform}/${file.screenSize}`;
|
|
744
|
+
if (movedBuckets.has(bucketKey)) {
|
|
745
|
+
try {
|
|
746
|
+
unlinkSync(file.tmpPath);
|
|
747
|
+
} catch {
|
|
748
|
+
}
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
movedBuckets.add(bucketKey);
|
|
741
752
|
const destDir = join4(outputDir, file.platform, file.screenSize);
|
|
742
753
|
mkdirSync(destDir, { recursive: true });
|
|
743
|
-
|
|
754
|
+
const destPath = join4(destDir, file.filename);
|
|
755
|
+
copyFileSync(file.tmpPath, destPath);
|
|
756
|
+
try {
|
|
757
|
+
unlinkSync(file.tmpPath);
|
|
758
|
+
} catch {
|
|
759
|
+
}
|
|
744
760
|
}
|
|
745
761
|
updateMetadata(outputDir, devices);
|
|
746
762
|
if (iosDevices.length > 0) {
|
|
@@ -857,7 +873,7 @@ async function frameCommand(dir, options) {
|
|
|
857
873
|
var program = new Command();
|
|
858
874
|
program.name("device-shots").description(
|
|
859
875
|
"Capture and frame mobile app screenshots from iOS simulators and Android emulators"
|
|
860
|
-
).version("0.4.
|
|
876
|
+
).version("0.4.1");
|
|
861
877
|
program.command("capture").description("Capture screenshots from running devices").argument("[name]", "Screenshot name").option("-b, --bundle-id <id>", "App bundle ID").option("-o, --output <dir>", "Output directory").option("-p, --platform <platform>", "ios, android, or both").option("--no-frame", "Skip framing after capture").option("--time <time>", "Status bar time", "9:41").action(async (name, opts) => {
|
|
862
878
|
await captureCommand({ name, ...opts });
|
|
863
879
|
});
|