@cliz/translate-weekly
Version:
Docschina weekly translate tool
23 lines (22 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setLastestPeriod = exports.getLastestPeriod = exports.getLastestPeriodFilePath = void 0;
const cli_1 = require("@cliz/cli");
async function getLastestPeriodFilePath() {
const latestPeriodFilePath = cli_1.api.path.join(process.cwd(), '.LATEST');
if (!await cli_1.api.fs.isExist(latestPeriodFilePath)) {
throw new Error(`请确认当前路径是否在翻译根目录`);
}
return latestPeriodFilePath;
}
exports.getLastestPeriodFilePath = getLastestPeriodFilePath;
async function getLastestPeriod() {
const latestPeriodFilePath = await getLastestPeriodFilePath();
return +await cli_1.api.fs.readFile(latestPeriodFilePath, { encoding: 'utf-8' });
}
exports.getLastestPeriod = getLastestPeriod;
async function setLastestPeriod(period) {
const latestPeriodFilePath = await getLastestPeriodFilePath();
await cli_1.api.fs.writeFile(latestPeriodFilePath, period + '\n', { encoding: 'utf-8' });
}
exports.setLastestPeriod = setLastestPeriod;