Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

CLI #215

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CLI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
path: repo
- uses: actions/setup-node@v1
with:
node-version: '12'
- run: mkdir work
- run: |
npm init --yes
npm install $GITHUB_WORKSPACE/repo
pwd
working-directory: ./work
- run: xvfb-run -a npx vscode-markdown-pdf pdf $GITHUB_WORKSPACE/repo/test/suite/mermaid.md
working-directory: ./work
47 changes: 47 additions & 0 deletions bin/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node

'use strict';

const path = require('path');
const { runTests } = require('vscode-test');

async function main() {
try {
if (process.argv.length != 4) { // ['node', 'bin/main.js', type, source]
usage();
throw 'invalid arguments';
}
const type = process.argv[2];
const source = process.argv[3];

// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './runner');

// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: ['--disable-extensions'],
extensionTestsEnv: { type, source }
});
} catch (err) {
console.error(err);
process.exit(1);
}
}

function usage() {
console.log(`
vscode-markdown-pdf TYPE FILE

TYPE A type of output; pdf, html, png, jpeg, or all.
FILE A source Markdown path.
`.trim());
}

main();
18 changes: 18 additions & 0 deletions bin/runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const vscode = require('vscode');

function run() {
return new Promise((c, e) => {
(async () => {
const type = process.env.type;
const source = process.env.source;
var document = await vscode.workspace.openTextDocument(source);
await vscode.window.showTextDocument(document);
await vscode.commands.executeCommand('extension.markdown-pdf.' + type);
c();
})()
});
}

exports.run = run;
15 changes: 2 additions & 13 deletions package-lock.json

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

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,17 @@
}
}
},
"bin": {
"vscode-markdown-pdf": "./bin/main.js"
},
"scripts": {
"vscode:prepublish": "node ./src/compile",
"test": "node ./test/runTest.js"
},
"devDependencies": {
"glob": "^7.1.6",
"mocha": "^7.1.1",
"removeNPMAbsolutePaths": "^2.0.0",
"vscode-test": "^1.3.0"
"removeNPMAbsolutePaths": "^2.0.0"
},
"dependencies": {
"cheerio": "^0.20.0",
Expand All @@ -505,6 +507,7 @@
"mkdirp": "^1.0.3",
"mustache": "^4.0.1",
"puppeteer-core": "^2.1.1",
"rimraf": "^3.0.2"
"rimraf": "^3.0.2",
"vscode-test": "^1.3.0"
}
}