@diskette/palette 0.23.0 → 0.23.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/cli/cli.js CHANGED
@@ -25,7 +25,7 @@ const grayOptions = grayColors.map((c) => {
25
25
  return { value: c, label: `${swatch}${capitalize(c)}` };
26
26
  });
27
27
  async function main() {
28
- p.intro(`palette v0.23.0`);
28
+ p.intro(`palette v0.23.1`);
29
29
  const results = await p.group({
30
30
  colors: () => p.groupMultiselect({
31
31
  message: 'Select accent colors',
@@ -2,7 +2,6 @@ export type OutputFile = {
2
2
  path: string;
3
3
  displayName: string;
4
4
  content: () => string;
5
- skipIfExists?: boolean;
6
5
  };
7
6
  export type WriteResult = {
8
7
  path: string;
@@ -10,11 +10,15 @@ function isAlphaColor(name) {
10
10
  }
11
11
  function alphaColorFile(name, outputPath) {
12
12
  const fileName = name === 'blackAlpha' ? 'black-alpha' : 'white-alpha';
13
+ const path = `${outputPath}/${fileName}.css`;
14
+ // Alpha files are silently skipped if they exist
15
+ if (existsSync(path)) {
16
+ return null;
17
+ }
13
18
  return {
14
- path: `${outputPath}/${fileName}.css`,
19
+ path,
15
20
  displayName: capitalize(fileName.replace('-', ' ')),
16
21
  content: () => css.alpha(palette[name]),
17
- skipIfExists: true,
18
22
  };
19
23
  }
20
24
  function paletteColorFiles(name, outputPath) {
@@ -51,7 +55,9 @@ export function buildOutputFiles(config) {
51
55
  const files = [];
52
56
  for (const name of colors) {
53
57
  if (isAlphaColor(name)) {
54
- files.push(alphaColorFile(name, outputPath));
58
+ const file = alphaColorFile(name, outputPath);
59
+ if (file)
60
+ files.push(file);
55
61
  }
56
62
  else {
57
63
  files.push(...paletteColorFiles(name, outputPath));
@@ -71,14 +77,12 @@ export async function confirmOverwrites(files) {
71
77
  const cwd = process.cwd();
72
78
  const newFiles = files.filter((f) => !existsSync(f.path));
73
79
  const existing = files.filter((f) => existsSync(f.path));
74
- // Files that should prompt for overwrite confirmation
75
- const promptable = existing.filter((f) => !f.skipIfExists);
76
- if (promptable.length === 0) {
80
+ if (existing.length === 0) {
77
81
  return newFiles;
78
82
  }
79
83
  const selected = await p.multiselect({
80
84
  message: 'These files already exist. Select to overwrite:',
81
- options: promptable.map((f) => ({
85
+ options: existing.map((f) => ({
82
86
  value: f.path,
83
87
  label: f.displayName,
84
88
  hint: relative(cwd, f.path),
@@ -90,7 +94,7 @@ export async function confirmOverwrites(files) {
90
94
  process.exit(0);
91
95
  }
92
96
  const selectedSet = new Set(selected);
93
- const toOverwrite = promptable.filter((f) => selectedSet.has(f.path));
97
+ const toOverwrite = existing.filter((f) => selectedSet.has(f.path));
94
98
  return [...newFiles, ...toOverwrite];
95
99
  }
96
100
  export function writeOutputFiles(files) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@diskette/palette",
3
3
  "type": "module",
4
- "version": "0.23.0",
4
+ "version": "0.23.1",
5
5
  "bin": {
6
6
  "palette": "./dist/cli/cli.js"
7
7
  },