ssg-api
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -8,2 +8,8 @@ # Change Log | ||
## [1.4.0] - 2023-01-22 | ||
### Added | ||
- Process only files that have been updated after output. | ||
## [1.3.2] - 2023-01-14 | ||
@@ -10,0 +16,0 @@ |
@@ -13,3 +13,3 @@ import { SsgContext } from "./SsgContext"; | ||
}; | ||
export declare type OutputFunc = (context: SsgContext, outputFile: SsgFile, outDir?: string) => Promise<void>; | ||
export declare type OutputFunc = (context: SsgContext, outputFile: SsgFile) => Promise<void>; | ||
/** | ||
@@ -16,0 +16,0 @@ * Static Site Generator |
import { promise as glob } from "glob-promise"; | ||
import { HtmlSsgFile } from "../../util"; | ||
import fs from "fs"; | ||
/** | ||
@@ -48,9 +49,23 @@ * A SsgStep that can perform replacements in files' contents. | ||
context.outputFile = contentsConfig.getOutputFile(context); | ||
for (const replacement of contentsConfig.replacements) { | ||
context.outputFile = await replacement.execute(context); | ||
let process; | ||
const exists = fs.existsSync(context.outputFile.name); | ||
if (exists) { | ||
const outStats = fs.statSync(context.outputFile.name); | ||
process = outStats.mtime < context.inputFile.lastModified; | ||
if (!process) { | ||
console.debug(context.inputFile.name, "is not older that current out file"); | ||
} | ||
} | ||
fileCount++; | ||
await this.output(context, context.outputFile); | ||
else { | ||
process = true; | ||
} | ||
if (process) { | ||
for (const replacement of contentsConfig.replacements) { | ||
context.outputFile = await replacement.execute(context); | ||
} | ||
fileCount++; | ||
await this.output(context, context.outputFile); | ||
} | ||
return fileCount; | ||
} | ||
} |
@@ -5,3 +5,3 @@ { | ||
"author": "Jérôme Beau", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Static Site Generation TypeScript API", | ||
@@ -23,4 +23,4 @@ "exports": "./dist/src/index.js", | ||
"prepublishOnly": "npm run build && npm test", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test-ci": "NODE_OPTIONS=--experimental-vm-modules jest --coverage" | ||
"test": "rm -Rf out && NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test-ci": "rm -Rf out && NODE_OPTIONS=--experimental-vm-modules jest --coverage" | ||
}, | ||
@@ -27,0 +27,0 @@ "dependencies": { |
@@ -19,15 +19,15 @@ # ssg-api [![CircleCI](https://dl.circleci.com/status-badge/img/gh/Javarome/ssg-api/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/Javarome/ssg-api/tree/main) | ||
```ts | ||
import {Ssg, SsgContextImpl, SsgConfig} from "ssg-api" | ||
import {Ssg, SsgContextImpl, SsgConfig} from "ssg-api"; | ||
const config: SsgConfig = {outDir: "out"} | ||
const config: SsgConfig = {outDir: "out"}; | ||
const ssg = new Ssg(config) | ||
.add(firstStep) | ||
.add(nextStep) | ||
.add(nextStep); // Write your own SSG steps! | ||
const context = new SsgContextImpl("fr") | ||
const context = new SsgContextImpl("fr"); | ||
try { | ||
const result = await ssg.start(context) | ||
console.log("Completed", result) | ||
} catch (e) { | ||
console.error(err, context.inputFile.name, "=>", context.outputFile.name) | ||
const result = await ssg.start(context); | ||
context.log("Completed", result); | ||
} catch (err) { | ||
context.error(err, context.inputFile.name, "=>", context.outputFile.name); | ||
} | ||
@@ -34,0 +34,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential malware
Supply chain riskAI has identified this package as malware. This is a strong signal that the package may be malicious.
Found 1 instance in 1 package
918230
190
3012
0
5