Skip to content

Commit

Permalink
fix: hanging on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Apr 8, 2021
2 parents 1a42e4b + b0bdc2b commit 221b751
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 189 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Release
on:
release:
types:
- created
pull_request:
branches: [master]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enexSource": "/test/data/test-template.enex",
"templateFile": "/sampleTemplate.tmpl",
"enexSource": "./test/data/test-template.enex",
"templateFile": "./sampleTemplate.tmpl",
"outputDir": "out",
"keepOriginalHtml": false,
"isMetadataNeeded": false,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yarle-evernote-to-md",
"version": "4.0.1",
"version": "4.0.3",
"description": "Yet Another Rope Ladder from Evernote",
"keywords": [
"evernote",
Expand All @@ -15,7 +15,8 @@
"yarle": "./dist/dropTheRope.js"
},
"scripts": {
"clean": "rimraf ./out && rimraf ./dist && rimraf \"node_modules/!(rimraf|.bin)\"",
"clean-by-rimraf": "rimraf ./out && rimraf ./dist && rimraf \"node_modules/!(rimraf|.bin)\"",
"clean": "rm -f -r ./out && rm -f -r ./dist && rm -r -f ./node_modules",
"build": "npm i && tsc --project ./src/tsconfig.json",
"build:watch": "nodemon --watch src/ --exec \"npm run build\" -e ts",
"coverage": "nyc mocha",
Expand All @@ -26,7 +27,7 @@
"package": "electron-forge package",
"make": "electron-forge make",
"compile": "npm run build && copyfiles -u 1 \"src/ui/**/*\" dist",
"start": "tsc --project ./src/tsconfig.json && electron-forge start",
"start": "tsc --project ./src/tsconfig.json && electron-forge start --inspect-electron",
"publish": "electron-forge publish",
"css-build": "node-sass --omit-source-map-url ./src/ui/sass/purecss.scss ./src/ui/css/purecss.css",
"css-watch": "npm run css-build -- --watch",
Expand Down
4 changes: 2 additions & 2 deletions src/process-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const processNode = (note: any, notebookName: string): void => {

let dateStarted: Date = new Date();
loggerInfo("\n");
loggerInfo("Started conversion: " + dateStarted);
loggerInfo("Conversion started at " + dateStarted);

if (Array.isArray(note.content))
note.content = note.content.join('');
Expand Down Expand Up @@ -58,7 +58,7 @@ export const processNode = (note: any, notebookName: string): void => {
// tslint:disable-next-line:no-console
let dateFinished: Date = new Date();
let conversionDuration = (dateFinished.getTime()- dateStarted.getTime())/1000; //in seconds.
loggerInfo("Finished conversion: " + dateFinished);
loggerInfo("Conversion finished at " + dateFinished);
loggerInfo(`Note "${noteData.title}" converted successfully in ${conversionDuration} seconds.`);


Expand Down
3 changes: 2 additions & 1 deletion src/ui/assets/js/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function startLogWatcher() {

function onWatcherReady() {
console.info('From here can you check for real changes, the initial scan has been completed.');
ipcRenderer.send('startConversion');

}

Expand Down Expand Up @@ -87,6 +86,8 @@ function(n) {

$('#startConversion').click(function () {
startLogWatcher();
ipcRenderer.send('startConversion');

});

$('#saveTemplate').click(function () {
Expand Down
6 changes: 1 addition & 5 deletions src/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createWindow () {
minHeight: 800,
backgroundColor: '#312450',
show: false,
icon: path.join(__dirname, 'assets/icons/png/64x64.png'),
icon: path.join(__dirname, 'assets/icons/png/192x192.png'),
webPreferences: {
nodeIntegration: true
}
Expand Down Expand Up @@ -82,9 +82,6 @@ function createWindow () {

secondWindow.loadURL(`file://${__dirname}/windows/ipcwindow.html`)

require('./menu/mainmenu')


mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, `../../src/ui/index.html`),
Expand Down Expand Up @@ -219,5 +216,4 @@ ipcMain.on('startConversion', async(event: any, data: any) => {
ipcMain.on('saveTemplate', async(event: any, data: any) => {
store.set(data.id, data.value);
console.log(`Template : ${data.value}`);
loggerInfo(`template and config: ${JSON.stringify(store.get(data.id))}`);
})
155 changes: 0 additions & 155 deletions src/ui/menu/mainmenu.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/ui/sections/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>Step 3: Set your template</h2>
</section>
<section>
<ul class="actions">
<li><a href="#" class="button" id="saveTemplate">Save</a></li>
<li><a href="#" class="button" name="saveTemplate" id="saveTemplate">Save</a></li>
</ul>
</section>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/ui/settingsMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export const mapSettingsToYarleOptions = (): YarleOptions => {
keepMDCharactersOfENNotes: store.get('keepMDCharactersOfENNotes') as boolean,
monospaceIsCodeBlock: store.get('monospaceIsCodeBlock') as boolean,
keepOriginalHtml: store.get('keepOriginalHtml') as boolean,
currentTemplate: store.get('currentTemplate') as string
}
}
5 changes: 2 additions & 3 deletions src/utils/clearLogFile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import { LOGFILE } from './loggerInfo';
export const clearLogFile = () => {
if (fs.existsSync(LOGFILE)){
fs.truncateSync(LOGFILE)
}

fs.unlinkSync(LOGFILE);
}
18 changes: 11 additions & 7 deletions src/utils/folder-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Path } from '../paths';
import { yarleOptions } from '../yarle';

import { getNoteFileName, getNoteName } from './filename-utils';
import { loggerInfo } from './loggerInfo';
import { logger } from './logger';

export const paths: Path = {};

Expand Down Expand Up @@ -38,11 +40,11 @@ const clearDistDir = (dstPath: string): void => {
};

export const getRelativeResourceDir = (note: any): string => {
return yarleOptions.haveEnexLevelResources ? './_resources' : `./_resources/${getResourceDir(paths.mdPath, note)}.resources`;
return yarleOptions.haveEnexLevelResources ? `.${path.sep}_resources` : `.${path.sep}_resources${path.sep}${getResourceDir(paths.mdPath, note)}.resources`;
};

export const getAbsoluteResourceDir = (note: any): string => {
return yarleOptions.haveEnexLevelResources ? paths.resourcePath : `${paths.resourcePath}/${getResourceDir(paths.mdPath, note)}.resources`;
return yarleOptions.haveEnexLevelResources ? paths.resourcePath : `${paths.resourcePath}${path.sep}${getResourceDir(paths.mdPath, note)}.resources`;
};

const resourceDirClears = new Map<string, number>();
Expand Down Expand Up @@ -71,20 +73,22 @@ export const clearMdNotesDistDir = (): void => {
};

export const setPaths = (): void => {
const enexFolder = yarleOptions.enexSource.split('/');
loggerInfo('setting paths');
const enexFolder = yarleOptions.enexSource.split(path.sep);
const enexFile = (enexFolder.length >= 1 ? enexFolder[enexFolder.length - 1] : enexFolder[0]).split('.')[0];
const outputDir = path.isAbsolute(yarleOptions.outputDir)
? yarleOptions.outputDir
: `${process.cwd()}/${yarleOptions.outputDir}`;
: `${process.cwd()}${path.sep}${yarleOptions.outputDir}`;

paths.mdPath = `${outputDir}/notes/`;
paths.resourcePath = `${outputDir}/notes/_resources`;
paths.mdPath = `${outputDir}${path.sep}notes${path.sep}`;
paths.resourcePath = `${outputDir}${path.sep}notes${path.sep}_resources`;
if (!yarleOptions.skipEnexFileNameFromOutputPath) {
paths.mdPath = `${paths.mdPath}${enexFile}`;
paths.resourcePath = `${outputDir}/notes/${enexFile}/_resources`;
paths.resourcePath = `${outputDir}${path.sep}notes${path.sep}${enexFile}${path.sep}_resources`;
}
fsExtra.mkdirsSync(paths.mdPath);
fsExtra.mkdirsSync(paths.resourcePath);
logger.info(`path ${paths.mdPath} created`);
// clearDistDir(paths.simpleMdPath);
// clearDistDir(paths.complexMdPath);
};
2 changes: 1 addition & 1 deletion src/utils/loggerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getAppDataPath = () => {
}
}

export const LOGFILE = path.join(getAppDataPath(),'/conversion.log');
export const LOGFILE = path.join(getAppDataPath(),'conversion.log');
console.log(`logfilepath: ${LOGFILE}`);


Expand Down
12 changes: 7 additions & 5 deletions src/yarle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export let yarleOptions: YarleOptions = { ...defaultYarleOptions };

const setOptions = (options: YarleOptions): void => {
yarleOptions = { ...defaultYarleOptions, ...options };
let template = yarleOptions.currentTemplate ? yarleOptions.currentTemplate : defaultTemplate;

if (yarleOptions.templateFile) {
template = fs.readFileSync(yarleOptions.templateFile, 'utf-8');
}

let template = (yarleOptions.templateFile) ? fs.readFileSync(yarleOptions.templateFile, 'utf-8'): defaultTemplate;
template = yarleOptions.currentTemplate ? yarleOptions.currentTemplate : template;

/*if (yarleOptions.templateFile) {*/
// todo: handle file not exists error
yarleOptions.skipCreationTime = !hasCreationTimeInTemplate(template);
Expand All @@ -49,11 +49,13 @@ const setOptions = (options: YarleOptions): void => {
yarleOptions.keepOriginalHtml = hasLinkToOriginalInTemplate(template);

yarleOptions.currentTemplate = template;

loggerInfo(`Current template is: ${template}`);
/*}*/
};

export const parseStream = async (options: YarleOptions): Promise<void> => {

// loggerInfo(`Getting stream from ${options.enexSource}`);
const stream = fs.createReadStream(options.enexSource);
// const xml = new XmlStream(stream);
let noteNumber = 0;
Expand Down

0 comments on commit 221b751

Please sign in to comment.