Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 形式のファイルパス対応 #272

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions node/src/build/Css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs';
import path from 'path';
import prettier from 'prettier';
import slash from 'slash';
import { globby } from 'globby';
import BuildComponent from '../BuildComponent.js';
import BuildComponentInterface from '../BuildComponentInterface.js';
Expand All @@ -10,13 +11,15 @@ import BuildComponentInterface from '../BuildComponentInterface.js';
*/
export default class Css extends BuildComponent implements BuildComponentInterface {
async execute(args: string[]): Promise<void> {
const filesPath = args.at(0);
const distDirectory = args.at(1);
if (filesPath === undefined) {
const filesPathOs = args.at(0);
const distDirectoryOs = args.at(1);
if (filesPathOs === undefined) {
throw new Error('Missing parameter');
}
const filesPath = slash(filesPathOs);
const distDirectory = distDirectoryOs !== undefined ? slash(distDirectoryOs) : undefined;

const fileList = await globby(filesPath.replace(/\\/g, '/'));
const fileList = await globby(filesPath);

const prettierOptions: prettier.Options = JSON.parse((await fs.promises.readFile('.prettierrc')).toString());
prettierOptions.parser = 'css';
Expand Down
10 changes: 6 additions & 4 deletions node/src/build/Html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ejs from 'ejs';
import fs from 'fs';
import path from 'path';
import prettier from 'prettier';
import slash from 'slash';
import { globby } from 'globby';
import { JSDOM } from 'jsdom';
import BuildComponent from '../BuildComponent.js';
Expand All @@ -28,12 +29,13 @@ import PageUrl from '../util/PageUrl.js';
*/
export default class Html extends BuildComponent implements BuildComponentInterface {
async execute(args: string[]): Promise<void> {
const filesPath = args.at(0);
if (filesPath === undefined) {
const filesPathOs = args.at(0);
if (filesPathOs === undefined) {
throw new Error('Missing parameter');
}
const filesPath = slash(filesPathOs);

const fileList = await globby(filesPath.replace(/\\/g, '/'));
const fileList = await globby(filesPath);

fileList.forEach(async (filePath) => {
/* ファイル読み込み */
Expand Down Expand Up @@ -168,7 +170,7 @@ export default class Html extends BuildComponent implements BuildComponentInterf
}

/* 出力 */
const distPath = `${this.configCommon.static.root}/${filePath.substring(filePath.replace(/\\/g, '/').indexOf('/') + 1)}`;
const distPath = `${this.configCommon.static.root}/${filePath.substring(filePath.indexOf('/') + 1)}`;
await fs.promises.writeFile(distPath, htmlFormatted);
this.logger.info(`HTML file created: ${distPath}`);
});
Expand Down
6 changes: 4 additions & 2 deletions node/src/build/HtmlImageSize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';
import slash from 'slash';
import { globby } from 'globby';
import { imageSize } from 'image-size';
import { JSDOM } from 'jsdom';
Expand All @@ -10,10 +11,11 @@ import BuildComponentInterface from '../BuildComponentInterface.js';
*/
export default class HtmlImageSize extends BuildComponent implements BuildComponentInterface {
async execute(args: string[]): Promise<void> {
const filesPath = args.at(0);
if (filesPath === undefined) {
const filesPathOs = args.at(0);
if (filesPathOs === undefined) {
throw new Error('Missing parameter');
}
const filesPath = slash(filesPathOs);

const fileList = await globby(filesPath);

Expand Down
6 changes: 4 additions & 2 deletions node/src/build/Sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dayjs from 'dayjs';
import ejs from 'ejs';
import fs from 'fs';
import slash from 'slash';
import { globby } from 'globby';
import { JSDOM } from 'jsdom';
import xmlFormatter from 'xml-formatter';
Expand All @@ -13,10 +14,11 @@ import PageUrl from '../util/PageUrl.js';
*/
export default class Sitemap extends BuildComponent implements BuildComponentInterface {
async execute(args: string[]): Promise<void> {
const filesPath = args.at(0);
if (filesPath === undefined) {
const filesPathOs = args.at(0);
if (filesPathOs === undefined) {
throw new Error('Missing parameter');
}
const filesPath = slash(filesPathOs);

const fileList = await globby(filesPath, {
ignore: this.configBuild.sitemap.ignore.map((filePath) => `${this.configBuild.html.directory}/${filePath}`),
Expand Down
51 changes: 26 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"prettier": "^2.8.7",
"qs": "^6.11.0",
"sharp": "^0.31.1",
"slash": "^5.0.0",
"sqlite": "^4.1.2",
"sqlite3": "^5.1.5",
"svgo": "^3.0.2",
Expand Down