mirror of https://gitee.com/cf-fz/WebCAD.git
parent
7b7067b60b
commit
e96cac1398
@ -1,46 +1,46 @@
|
||||
import { resolve } from "path";
|
||||
import { copyFileSync } from "./copy_type";
|
||||
import { copyFileSync } from "./utils";
|
||||
|
||||
const gitlog = require('gitlog');
|
||||
|
||||
const options =
|
||||
{
|
||||
repo: __dirname
|
||||
, number: 50
|
||||
, fields:
|
||||
['subject', 'authorName', "authorDate"]
|
||||
, execOptions:
|
||||
{
|
||||
maxBuffer: 1000 * 1024
|
||||
}
|
||||
repo: __dirname
|
||||
, number: 50
|
||||
, fields:
|
||||
['subject', 'authorName', "authorDate"]
|
||||
, execOptions:
|
||||
{
|
||||
maxBuffer: 1000 * 1024
|
||||
}
|
||||
};
|
||||
|
||||
let commits = gitlog(options);
|
||||
|
||||
let cs = commits.map(c =>
|
||||
{
|
||||
return {
|
||||
subject: c.subject,
|
||||
auther: c.authorName,
|
||||
time: c.authorDate
|
||||
}
|
||||
return {
|
||||
subject: c.subject,
|
||||
auther: c.authorName,
|
||||
time: c.authorDate
|
||||
}
|
||||
});
|
||||
|
||||
const fs = require('fs');
|
||||
fs.writeFile("./dist/log.json", JSON.stringify(cs, null, 2), function (err)
|
||||
{
|
||||
if (err)
|
||||
console.log("日志写入失败", err);
|
||||
else
|
||||
console.log("日志写入成功");
|
||||
if (err)
|
||||
console.log("日志写入失败", err);
|
||||
else
|
||||
console.log("日志写入成功");
|
||||
});
|
||||
|
||||
fs.writeFile("./dist/ver.json", Date.now(), err =>
|
||||
{
|
||||
if (err)
|
||||
console.log("版本写入失败", err);
|
||||
else
|
||||
console.log("版本写入成功");
|
||||
if (err)
|
||||
console.log("版本写入失败", err);
|
||||
else
|
||||
console.log("版本写入成功");
|
||||
});
|
||||
|
||||
copyFileSync(resolve("./utils/log.html"), resolve("./dist/"));
|
||||
|
@ -0,0 +1,69 @@
|
||||
import * as path from 'path';
|
||||
import * as http from 'https';
|
||||
import * as fs from "fs";
|
||||
|
||||
/**
|
||||
* 下载文件到指定的文件地址
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} filePath
|
||||
*/
|
||||
export function downLoadFile(url: string, filePath: string)
|
||||
{
|
||||
if (fs.existsSync(filePath))
|
||||
fs.unlinkSync(filePath);
|
||||
else
|
||||
fs.mkdirSync(path.dirname(filePath));
|
||||
let file = fs.createWriteStream(filePath);
|
||||
http.get(url, function (response)
|
||||
{
|
||||
response.pipe(file);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文件.
|
||||
*
|
||||
* @param {*} source 目标文件的地址
|
||||
* @param {*} targetFile 拷贝到新的地址
|
||||
*/
|
||||
export function copyFileSync(source: string, targetFile: string)
|
||||
{
|
||||
//if target is a directory a new file with the same name will be created
|
||||
if (fs.existsSync(targetFile))
|
||||
{
|
||||
if (fs.lstatSync(targetFile).isDirectory())
|
||||
{
|
||||
targetFile = path.join(targetFile, path.basename(source));
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
||||
console.log('targetFile: ', targetFile);
|
||||
}
|
||||
|
||||
export function copyFolderRecursiveSync(source, target)
|
||||
{
|
||||
let files = [];
|
||||
//check if folder needs to be created or integrated
|
||||
let targetFolder = path.join(target, path.basename(source));
|
||||
if (!fs.existsSync(targetFolder))
|
||||
{
|
||||
fs.mkdirSync(targetFolder);
|
||||
}
|
||||
//copy
|
||||
if (fs.lstatSync(source).isDirectory())
|
||||
{
|
||||
files = fs.readdirSync(source);
|
||||
files.forEach(function (file)
|
||||
{
|
||||
let curSource = path.join(source, file);
|
||||
if (fs.lstatSync(curSource).isDirectory())
|
||||
{
|
||||
copyFolderRecursiveSync(curSource, targetFolder);
|
||||
} else
|
||||
{
|
||||
copyFileSync(curSource, targetFolder);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in new issue