-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit abd43e9
Showing
16 changed files
with
1,394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Publish to NPM | ||
on: | ||
release: | ||
types: [ created ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
# Setup .npmrc file to publish to npm | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '12.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm install | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
torchlight.config.js | ||
source | ||
built | ||
.idea | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
torchlight.config.js | ||
source | ||
built | ||
.idea |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#! /usr/bin/env node | ||
const {program} = require('commander') | ||
const torchlight = require('./src/torchlight'); | ||
|
||
command('_default_') | ||
.alias('highlight') | ||
.description('Highlight <code> blocks in source files') | ||
.option('-i, --input <directory>', 'Input directory') | ||
.option('-o, --output <directory>', 'Output directory') | ||
.option('-g, --globs <pattern>', 'Glob patterns used to search for source files. Separate multiple patterns with commas.') | ||
.option('-x, --ignore <pattern>', 'Glob patterns used to ignore source files. Separate multiple patterns with commas.') | ||
.option('-w, --watch', 'Watch source files for changes') | ||
|
||
command('init') | ||
.option('-p, --path <path>', 'Location for the configuration file') | ||
.description('Publish the Torchlight configuration file'); | ||
|
||
command('cache:clear') | ||
.description('Clear the cache'); | ||
|
||
// Bootstrap the Torchlight singleton before every command. | ||
program.hook('preAction', thisCommand => { | ||
torchlight.init(thisCommand.opts().config) | ||
}) | ||
|
||
program.parse() | ||
|
||
// A helper function to define commands. It takes | ||
// care of several defaults for every command. | ||
function command(name) { | ||
let cmd = program; | ||
let action = name; | ||
|
||
// The default command has no name. | ||
if (name !== '_default_') { | ||
cmd = cmd.command(name); | ||
} else { | ||
action = 'highlight'; | ||
} | ||
|
||
// Namespaced command convention. The command config:cache | ||
// has a handler at config/cache.js. | ||
action = action.replace(':', '/'); | ||
|
||
let handler = require(`./src/commands/${action}`); | ||
|
||
// Add a little shim around the handler so we can pass the | ||
// torchlight variable in, just for convenience. | ||
cmd.action(function (options) { | ||
return handler(torchlight, options); | ||
}) | ||
|
||
// Options config path | ||
return cmd.option('-c, --config <file>', 'Path to the Torchlight configuration file.') | ||
} |
Oops, something went wrong.