UNPKG

@nx/remix

Version:

The Remix plugin for Nx contains executors and generators for managing Remix applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Vitest, Jest, Playwright, Cypress, and Storybook. - Generators for applica

23 lines (22 loc) 852 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.insertStatementInDefaultFunction = insertStatementInDefaultFunction; const devkit_1 = require("@nx/devkit"); const get_default_export_1 = require("./get-default-export"); function insertStatementInDefaultFunction(tree, path, statement) { const defaultExport = (0, get_default_export_1.getDefaultExport)(tree, path); if (!defaultExport) { throw Error('No default export found!'); } const index = defaultExport.body.statements.length > 0 ? defaultExport.body.statements[0].pos : 0; const newContents = (0, devkit_1.applyChangesToString)(tree.read(path, 'utf-8'), [ { type: devkit_1.ChangeType.Insert, index, text: statement, }, ]); tree.write(path, newContents); }