forked from mklabs/tabtab
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: bundle template files as 1 json file
This should allow the pnpm build script to stop copying the template files from this library to pnpm's `dist` assuming the bundle script used by pnpm can bundle JSON. BREAKING CHANGE: `getCompletionScript` no longer returns a `Promise`
- Loading branch information
Showing
10 changed files
with
54 additions
and
34 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 |
---|---|---|
|
@@ -11,3 +11,4 @@ coverage/ | |
tabtab/ | ||
test/tabtab.log | ||
/types | ||
/lib/templates/data.json |
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
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
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
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
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,19 @@ | ||
#! /usr/bin/env node | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const templateFiles = fs.readdirSync(__dirname).filter(name => name.startsWith('completion.')); | ||
|
||
/** @type {Record.<String, String>} */ | ||
const jsonData = {} | ||
|
||
for (const templateFileName of templateFiles) { | ||
const templateFilePath = path.join(__dirname, templateFileName); | ||
const templateContent = fs.readFileSync(templateFilePath, 'utf-8'); | ||
const ext = templateFileName.replace('completion.', ''); | ||
jsonData[ext] = templateContent; | ||
} | ||
|
||
const jsonFilePath = path.join(__dirname, 'data.json'); | ||
const jsonText = JSON.stringify(jsonData); | ||
fs.writeFileSync(jsonFilePath, jsonText); |
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,13 @@ | ||
const { completionFileExt } = require('../filename'); | ||
const data = require('./data.json'); | ||
|
||
/** | ||
* | ||
* @param {import('../constants').SupportedShell} shell | ||
* @returns {String} | ||
*/ | ||
const getTemplate = shell => data[completionFileExt(shell)]; | ||
|
||
module.exports = { | ||
getTemplate, | ||
}; |
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
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
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 |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
"module": "Node16", | ||
"strictNullChecks": true, | ||
"target": "ES2022", | ||
"resolveJsonModule": true, | ||
} | ||
} |