Skip to content

Commit f880ae5

Browse files
committed
Update prettier config
1 parent d75648f commit f880ae5

File tree

11 files changed

+330
-321
lines changed

11 files changed

+330
-321
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
node_modules
3+
yarn.lock

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"semi": true,
4+
"singleQuote": true,
5+
"useTabs": true
6+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"[md]": {
1111
"editor.defaultFormatter": "esbenp.prettier-vscode"
1212
}
13-
}
13+
}

@types/types.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare type Options = {
2-
filename?: string;
3-
folderPath?: string;
4-
width: number;
5-
height?: number;
2+
filename?: string;
3+
folderPath?: string;
4+
width: number;
5+
height?: number;
66
};

package.json

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
{
2-
"name": "node-image-slice",
3-
"version": "2.0.0",
4-
"description": "Slices an input image into segments according to specified width and height",
5-
"repository": {
6-
"type": "git",
7-
"url": "https://github.com/thinknathan/node-image-slice.git"
8-
},
9-
"author": "Nathan Bolton (https://thinknathan.ca/)",
10-
"license": "CC0-1.0",
11-
"type": "commonjs",
12-
"main": "slice.cjs",
13-
"bin": {
14-
"slice": "./slice.cjs"
15-
},
16-
"files": [
17-
"slice.cjs",
18-
"utils"
19-
],
20-
"scripts": {
21-
"build": "tsc && npm run renameCjs && npm run prettier",
22-
"renameCjs": "node -e \"require('fs').renameSync('slice.js', 'slice.cjs')\"",
23-
"prettier": "prettier \"./**/*.{ts,d.ts,cjs,md,json}\" --write"
24-
},
25-
"devDependencies": {
26-
"@types/yargs": "^17.0.32",
27-
"prettier": "^3.1.1",
28-
"tsc": "^2.0.4",
29-
"typescript": "~5.2.2"
30-
},
31-
"dependencies": {
32-
"jimp": "~0.22.10",
33-
"yargs": "^17.7.2"
34-
}
2+
"name": "node-image-slice",
3+
"version": "2.0.0",
4+
"description": "Slices an input image into segments according to specified width and height",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/thinknathan/node-image-slice.git"
8+
},
9+
"author": "Nathan Bolton (https://thinknathan.ca/)",
10+
"license": "CC0-1.0",
11+
"type": "commonjs",
12+
"main": "slice.cjs",
13+
"bin": {
14+
"slice": "./slice.cjs"
15+
},
16+
"files": [
17+
"slice.cjs",
18+
"utils"
19+
],
20+
"scripts": {
21+
"build": "tsc && npm run renameCjs && npm run prettier",
22+
"renameCjs": "node -e \"require('fs').renameSync('slice.js', 'slice.cjs')\"",
23+
"prettier": "prettier \"./**/*.{ts,d.ts,cjs,md,json}\" --write"
24+
},
25+
"devDependencies": {
26+
"@types/yargs": "^17.0.32",
27+
"prettier": "^3.1.1",
28+
"tsc": "^2.0.4",
29+
"typescript": "~5.2.2"
30+
},
31+
"dependencies": {
32+
"jimp": "~0.22.10",
33+
"yargs": "^17.7.2"
34+
}
3535
}

slice.cjs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
#!/usr/bin/env node
2-
"use strict";
3-
Object.defineProperty(exports, "__esModule", { value: true });
4-
const yargs = require("yargs");
5-
const os = require("os");
6-
const processImage_1 = require("./utils/processImage");
7-
const processPath_1 = require("./utils/processPath");
2+
'use strict';
3+
Object.defineProperty(exports, '__esModule', { value: true });
4+
const yargs = require('yargs');
5+
const os = require('os');
6+
const processImage_1 = require('./utils/processImage');
7+
const processPath_1 = require('./utils/processPath');
88
// Parse command line arguments
99
const options = yargs
10-
.option("f", {
11-
alias: "filename",
12-
describe: "Input image filename",
13-
type: "string",
14-
})
15-
.option("i", {
16-
alias: "folderPath",
17-
describe: "Input folder",
18-
type: "string",
19-
})
20-
.option("w", {
21-
alias: "width",
22-
describe: "Output image width",
23-
type: "number",
24-
demandOption: true,
25-
coerce: (value) => {
26-
if (value < 1) {
27-
throw new Error("width should not be lower than 1");
28-
}
29-
return Math.round(value);
30-
},
31-
})
32-
.option("h", {
33-
alias: "height",
34-
describe: "Output image height",
35-
type: "number",
36-
coerce: (value) => {
37-
if (value !== undefined && value < 1) {
38-
throw new Error("height should not be lower than 1");
39-
}
40-
return Math.round(value);
41-
},
42-
}).argv;
10+
.option('f', {
11+
alias: 'filename',
12+
describe: 'Input image filename',
13+
type: 'string',
14+
})
15+
.option('i', {
16+
alias: 'folderPath',
17+
describe: 'Input folder',
18+
type: 'string',
19+
})
20+
.option('w', {
21+
alias: 'width',
22+
describe: 'Output image width',
23+
type: 'number',
24+
demandOption: true,
25+
coerce: (value) => {
26+
if (value < 1) {
27+
throw new Error('width should not be lower than 1');
28+
}
29+
return Math.round(value);
30+
},
31+
})
32+
.option('h', {
33+
alias: 'height',
34+
describe: 'Output image height',
35+
type: 'number',
36+
coerce: (value) => {
37+
if (value !== undefined && value < 1) {
38+
throw new Error('height should not be lower than 1');
39+
}
40+
return Math.round(value);
41+
},
42+
}).argv;
4343
if (options.filename) {
44-
// Process a single image
45-
const { filename, width, height } = options;
46-
(0, processImage_1.sliceImage)(filename, width, height);
44+
// Process a single image
45+
const { filename, width, height } = options;
46+
(0, processImage_1.sliceImage)(filename, width, height);
4747
} else if (options.folderPath) {
48-
// Process all images in a folder, splitting the task into threads
49-
let numCores = 2;
50-
try {
51-
numCores = os.cpus().length;
52-
} catch (err) {
53-
console.error(err);
54-
}
55-
numCores = Math.max(numCores - 1, 1);
56-
(0, processPath_1.processPath)(options.folderPath, options, numCores);
48+
// Process all images in a folder, splitting the task into threads
49+
let numCores = 2;
50+
try {
51+
numCores = os.cpus().length;
52+
} catch (err) {
53+
console.error(err);
54+
}
55+
numCores = Math.max(numCores - 1, 1);
56+
(0, processPath_1.processPath)(options.folderPath, options, numCores);
5757
} else {
58-
console.log(
59-
"Requires either `filename` or `folderPath`. Run `slice --help` for help.",
60-
);
58+
console.log(
59+
'Requires either `filename` or `folderPath`. Run `slice --help` for help.',
60+
);
6161
}

src/slice.ts

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
#!/usr/bin/env node
22

3-
import * as yargs from "yargs";
4-
import * as os from "os";
3+
import * as yargs from 'yargs';
4+
import * as os from 'os';
55

6-
import { sliceImage } from "./utils/processImage";
7-
import { processPath } from "./utils/processPath";
6+
import { sliceImage } from './utils/processImage';
7+
import { processPath } from './utils/processPath';
88

99
// Parse command line arguments
1010
const options = yargs
11-
.option("f", {
12-
alias: "filename",
13-
describe: "Input image filename",
14-
type: "string",
15-
})
16-
.option("i", {
17-
alias: "folderPath",
18-
describe: "Input folder",
19-
type: "string",
20-
})
21-
.option("w", {
22-
alias: "width",
23-
describe: "Output image width",
24-
type: "number",
25-
demandOption: true,
26-
coerce: (value) => {
27-
if (value < 1) {
28-
throw new Error("width should not be lower than 1");
29-
}
30-
return Math.round(value);
31-
},
32-
})
33-
.option("h", {
34-
alias: "height",
35-
describe: "Output image height",
36-
type: "number",
37-
coerce: (value) => {
38-
if (value !== undefined && value < 1) {
39-
throw new Error("height should not be lower than 1");
40-
}
41-
return Math.round(value);
42-
},
43-
}).argv as unknown as Options;
11+
.option('f', {
12+
alias: 'filename',
13+
describe: 'Input image filename',
14+
type: 'string',
15+
})
16+
.option('i', {
17+
alias: 'folderPath',
18+
describe: 'Input folder',
19+
type: 'string',
20+
})
21+
.option('w', {
22+
alias: 'width',
23+
describe: 'Output image width',
24+
type: 'number',
25+
demandOption: true,
26+
coerce: (value) => {
27+
if (value < 1) {
28+
throw new Error('width should not be lower than 1');
29+
}
30+
return Math.round(value);
31+
},
32+
})
33+
.option('h', {
34+
alias: 'height',
35+
describe: 'Output image height',
36+
type: 'number',
37+
coerce: (value) => {
38+
if (value !== undefined && value < 1) {
39+
throw new Error('height should not be lower than 1');
40+
}
41+
return Math.round(value);
42+
},
43+
}).argv as unknown as Options;
4444

4545
if (options.filename) {
46-
// Process a single image
47-
const { filename, width, height } = options;
48-
sliceImage(filename, width, height);
46+
// Process a single image
47+
const { filename, width, height } = options;
48+
sliceImage(filename, width, height);
4949
} else if (options.folderPath) {
50-
// Process all images in a folder, splitting the task into threads
51-
let numCores = 2;
52-
try {
53-
numCores = os.cpus().length;
54-
} catch (err) {
55-
console.error(err);
56-
}
57-
numCores = Math.max(numCores - 1, 1);
58-
processPath(options.folderPath, options, numCores);
50+
// Process all images in a folder, splitting the task into threads
51+
let numCores = 2;
52+
try {
53+
numCores = os.cpus().length;
54+
} catch (err) {
55+
console.error(err);
56+
}
57+
numCores = Math.max(numCores - 1, 1);
58+
processPath(options.folderPath, options, numCores);
5959
} else {
60-
console.log(
61-
"Requires either `filename` or `folderPath`. Run `slice --help` for help.",
62-
);
60+
console.log(
61+
'Requires either `filename` or `folderPath`. Run `slice --help` for help.',
62+
);
6363
}

0 commit comments

Comments
 (0)