From 3677161ee6093d44a30f493537e978da4f049bfa Mon Sep 17 00:00:00 2001 From: dimaslanjaka Date: Thu, 3 Oct 2024 15:53:19 +0700 Subject: [PATCH] import from upstream/master --- lib/hexo/load_plugins.ts | 2 +- lib/hexo/render.ts | 4 ++-- lib/hexo/update_package.ts | 2 +- lib/plugins/helper/number_format.ts | 2 +- lib/plugins/renderer/nunjucks.ts | 2 +- lib/plugins/tag/include_code.ts | 2 +- package.json | 2 +- test/scripts/console/config.ts | 4 ++-- test/scripts/console/render.ts | 8 ++++---- test/scripts/hexo/update_package.ts | 6 +++--- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/hexo/load_plugins.ts b/lib/hexo/load_plugins.ts index 49802f9292..3c21df4ea5 100644 --- a/lib/hexo/load_plugins.ts +++ b/lib/hexo/load_plugins.ts @@ -19,7 +19,7 @@ function loadModuleList(ctx: Hexo, basedir: string): Promise { // Read package.json and find dependencies return readFile(packagePath).then(content => { - const json = JSON.parse(content as string); + const json = JSON.parse(content); const deps = Object.keys(json.dependencies || {}); const devDeps = Object.keys(json.devDependencies || {}); diff --git a/lib/hexo/render.ts b/lib/hexo/render.ts index 969b9eab5c..86c3bde64a 100644 --- a/lib/hexo/render.ts +++ b/lib/hexo/render.ts @@ -78,7 +78,7 @@ class Render { } else if (!data.path) { return Promise.reject(new TypeError('No input file or string!')); } else { - promise = readFile(data.path) as Promise; + promise = readFile(data.path); } return promise @@ -120,7 +120,7 @@ class Render { if (data.text == null) { if (!data.path) throw new TypeError('No input file or string!'); - data.text = readFileSync(data.path) as string; + data.text = readFileSync(data.path); } if (data.text == null) throw new TypeError('No input file or string!'); diff --git a/lib/hexo/update_package.ts b/lib/hexo/update_package.ts index 7913a67f67..ba95086e16 100644 --- a/lib/hexo/update_package.ts +++ b/lib/hexo/update_package.ts @@ -25,7 +25,7 @@ function readPkg(path: string): Promise { if (!exist) return; return readFile(path).then(content => { - const pkg = JSON.parse(content as string); + const pkg = JSON.parse(content); if (typeof pkg.hexo !== 'object') return; return pkg; diff --git a/lib/plugins/helper/number_format.ts b/lib/plugins/helper/number_format.ts index 477e50e892..5d92575bd8 100644 --- a/lib/plugins/helper/number_format.ts +++ b/lib/plugins/helper/number_format.ts @@ -6,7 +6,7 @@ interface Options { function numberFormatHelper(num: number, options: Options = {}) { const split = num.toString().split('.'); - let before = split.shift() as string; + let before = split.shift(); let after = split.length ? split[0] : ''; const delimiter = options.delimiter || ','; const separator = options.separator || '.'; diff --git a/lib/plugins/renderer/nunjucks.ts b/lib/plugins/renderer/nunjucks.ts index 75397e3caf..43e484df5e 100644 --- a/lib/plugins/renderer/nunjucks.ts +++ b/lib/plugins/renderer/nunjucks.ts @@ -53,7 +53,7 @@ function njkCompile(data: StoreFunctionData): nunjucks.Template { const text = 'text' in data ? data.text : readFileSync(data.path); - return nunjucks.compile(text as string, env, data.path); + return nunjucks.compile(text, env, data.path); } // function with internal exported function needs interface to detect from IDE diff --git a/lib/plugins/tag/include_code.ts b/lib/plugins/tag/include_code.ts index e54d89b2f1..589c020ce0 100644 --- a/lib/plugins/tag/include_code.ts +++ b/lib/plugins/tag/include_code.ts @@ -54,7 +54,7 @@ export = (ctx: Hexo) => function includeCodeTag(args: string[]) { return exists(src).then(exist => { if (exist) return readFile(src); - }).then((code: string) => { + }).then(code => { if (!code) return; const lines = code.split('\n'); diff --git a/package.json b/package.json index 15e4ee3c76..855a32d6a9 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "bluebird": "^3.7.2", "hexo-cli": "^4.3.0", "hexo-front-matter": "^4.2.1", - "hexo-fs": "^4.1.1", + "hexo-fs": "^4.1.3", "hexo-i18n": "^2.0.0", "hexo-log": "^4.0.1", "hexo-util": "^3.3.0", diff --git a/test/scripts/console/config.ts b/test/scripts/console/config.ts index 3395e12756..0a70da3c73 100644 --- a/test/scripts/console/config.ts +++ b/test/scripts/console/config.ts @@ -65,7 +65,7 @@ describe('config', () => { async function writeConfig(...args) { await config({_: args}); - const content = await readFile(hexo.config_path) as string; + const content = await readFile(hexo.config_path); return load(content) as any; } @@ -107,7 +107,7 @@ describe('config', () => { await config({_: ['title', 'My Blog']}); return readFile(configPath).then(content => { - const json = JSON.parse(content as string); + const json = JSON.parse(content); json.title.should.eql('My Blog'); diff --git a/test/scripts/console/render.ts b/test/scripts/console/render.ts index d79ef572e1..784c5d397e 100644 --- a/test/scripts/console/render.ts +++ b/test/scripts/console/render.ts @@ -43,7 +43,7 @@ describe('render', () => { await writeFile(src, body); await render({_: ['test.yml'], output: 'result.json'}); - const result = await readFile(dest) as string; + const result = await readFile(dest); JSON.parse(result).should.eql({ foo: 1, bar: { @@ -64,7 +64,7 @@ describe('render', () => { await writeFile(src, body); await render({_: [src], output: 'result.json'}); - const result = await readFile(dest) as string; + const result = await readFile(dest); JSON.parse(result).should.eql({ foo: 1, bar: { @@ -85,7 +85,7 @@ describe('render', () => { await writeFile(src, body); await render({_: ['test.yml'], output: dest}); - const result = await readFile(dest) as string; + const result = await readFile(dest); JSON.parse(result).should.eql({ foo: 1, bar: { @@ -108,7 +108,7 @@ describe('render', () => { await writeFile(src, body); await render({_: ['test'], output: 'result.json', engine: 'yaml'}); - const result = await readFile(dest) as string; + const result = await readFile(dest); JSON.parse(result).should.eql({ foo: 1, bar: { diff --git a/test/scripts/hexo/update_package.ts b/test/scripts/hexo/update_package.ts index b2b440bcd9..eaa7876091 100644 --- a/test/scripts/hexo/update_package.ts +++ b/test/scripts/hexo/update_package.ts @@ -25,7 +25,7 @@ describe('Update package.json', () => { await writeFile(packagePath, JSON.stringify(pkg)); await updatePkg(hexo); - const content = await readFile(packagePath) as string; + const content = await readFile(packagePath); JSON.parse(content).hexo.version.should.eql(hexo.version); hexo.env.init.should.be.true; @@ -40,7 +40,7 @@ describe('Update package.json', () => { await writeFile(packagePath, JSON.stringify(pkg)); await updatePkg(hexo); - const content = await readFile(packagePath) as string; + const content = await readFile(packagePath); // Don't change the original package.json JSON.parse(content).should.eql(pkg); hexo.env.init.should.be.false; @@ -57,7 +57,7 @@ describe('Update package.json', () => { await writeFile(packagePath, JSON.stringify(pkg)); await updatePkg(hexo); - const content = await readFile(packagePath) as string; + const content = await readFile(packagePath); JSON.parse(content).should.eql(pkg); hexo.env.init.should.be.true;