Skip to content

Commit

Permalink
feat: --out-name
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Nov 27, 2020
1 parent 90aa34c commit 4968cb3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/actions/uploadJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = async (jsonPath, options) => {
replace('T', '_').
replace('Z', '');
// const dateStr = date.slice(0,10);
const name = path.basename(jsonPath).replace(/[^0-9a-zа-я_.]/ig, '');
const name = path.basename(jsonPath).replace(/[^0-9a-zа-я_-.]/ig, '');
const uploadName = date + '_' + name;

console.log('\nUploading to https://site-audit.viasite.ru...');
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ program.option('-u --urls <urls>', 'Comma separated url list for scan', list).
option('--no-remove-json', `No delete json after serve`).
option('--out-dir <dir>', `Output directory`,
getConfigVal('outDir', '~/site-audit-seo/')).
option('--out-name <name>', `Output file name, default: domain`).
option('--csv <path>', `Skip scan, only convert csv to xlsx`).
option('--xlsx', `Save as XLSX`, getConfigVal('xlsx', false)).
option('--gdrive', `Publish sheet to google docs`,
Expand Down Expand Up @@ -228,6 +229,7 @@ async function start() {
headless: program.headless, // на десктопе открывает браузер визуально
docsExtensions: program.docsExtensions, // расширения, которые будут добавлены в таблицу
outDir: program.outDir, // папка, куда сохраняются csv
outName: program.outName, // имя файла
color: program.color, // раскрашивать консоль
lang: program.lang, // язык
openFile: program.openFile, // открыть файл после сканирования
Expand Down
7 changes: 4 additions & 3 deletions src/scrap-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ module.exports = async (baseUrl, options = {}) => {
const domain = url.parse(baseUrl).hostname;
const protocol = url.parse(baseUrl).protocol;

const csvPath = path.normalize(`${options.outDir}/${domain}.csv`);
const xlsxPath = path.normalize(`${options.outDir}/${domain}.xlsx`);
const jsonPath = path.normalize(`${options.outDir}/${domain}.json`);
const baseName = options.outName || domain;
const csvPath = path.normalize(`${options.outDir}/${baseName}.csv`);
const xlsxPath = path.normalize(`${options.outDir}/${baseName}.xlsx`);
const jsonPath = path.normalize(`${options.outDir}/${baseName}.json`);
let webPath;

if (!options.color) color.white = color.red = color.reset = color.yellow = '';
Expand Down

0 comments on commit 4968cb3

Please sign in to comment.