Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
vscode task for re-exporting an ember addon file that is open in the addon dir to the app dir
// bin/generate-reexport-in-app.js
const fs = require('fs');
const path = require('path');
let args = process.argv.slice(2);
let sourcePath = args[0];
let targetPath = sourcePath.replace(/^addon/,'app').replace(/^\.hbs/, '.js');
let pkg = require('../package.json');
let addonName =;
let sourceModule = sourcePath.replace(/^addon/,addonName).replace(/\.(js|hbs)$/,'');
let fileContents = `export { default } from '${sourceModule}';\n`;
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
fs.writeFileSync(targetPath, fileContents);
console.log(`Generated a re-export at ${targetPath}`);
// .vscode/tasks.json
"version": "2.0.0",
"tasks": [
"label": "re-export",
"type": "shell",
"command": "node ./bin/generate-reexport-in-app.js ${relativeFile}",
"problemMatcher": []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment