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

fix: Macro replacement works on Windows #76

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions util/docs/macros/index.mjs
Expand Up @@ -25,8 +25,6 @@ import { getPath, getExternalPath, getExternalSchemaPaths, getSchemaConstraints,
import fs from 'fs'
import pointfree from 'crocks/pointfree/index.js'
const { filter, option, map } = pointfree
import isArray from 'crocks/predicates/isArray.js'
import safe from 'crocks/Maybe/safe.js'
import { getProvidedCapabilities, isRPCOnlyMethod, isTemporalSetMethod, isProviderInterfaceMethod } from '../../shared/modules.mjs'

var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
Expand Down
22 changes: 11 additions & 11 deletions util/sdk/macros/index.mjs
Expand Up @@ -236,21 +236,21 @@ const generateMacros = templates => obj => {
}

const insertAggregateMacrosOnly = (fContents = '', aggregateMacros = {}) => {
fContents = fContents.replace(/[ \t]*\/\* \$\{EXPORTS\} \*\/[ \t]*\n/, aggregateMacros.exports)
fContents = fContents.replace(/[ \t]*\/\* \$\{MOCK_IMPORTS\} \*\/[ \t]*\n/, aggregateMacros.mockImports)
fContents = fContents.replace(/[ \t]*\/\* \$\{MOCK_OBJECTS\} \*\/[ \t]*\n/, aggregateMacros.mockObjects)
fContents = fContents.replace(/[ \t]*\/\* \$\{EXPORTS\} \*\/[ \t\r]*\n/, aggregateMacros.exports)
fContents = fContents.replace(/[ \t]*\/\* \$\{MOCK_IMPORTS\} \*\/[ \t\r]*\n/, aggregateMacros.mockImports)
fContents = fContents.replace(/[ \t]*\/\* \$\{MOCK_OBJECTS\} \*\/[ \t\r]*\n/, aggregateMacros.mockObjects)
return fContents
}

const insertMacros = (fContents = '', macros = {}, module = {}, version = {}) => {
fContents = fContents.replace(/[ \t]*\/\* \$\{METHODS\} \*\/[ \t]*\n/, macros.methods)
fContents = fContents.replace(/[ \t]*\/\* \$\{METHOD_LIST\} \*\/[ \t]*\n/, macros.methodList)
fContents = fContents.replace(/[ \t]*\/\* \$\{ENUMS\} \*\/[ \t]*\n/, macros.enums)
fContents = fContents.replace(/[ \t]*\/\* \$\{EVENTS\} \*\/[ \t]*\n/, macros.events)
fContents = fContents.replace(/[ \t]*\/\* \$\{IMPORTS\} \*\/[ \t]*\n/, macros.imports)
fContents = fContents.replace(/[ \t]*\/\* \$\{INITIALIZATION\} \*\/[ \t]*\n/, macros.initialization)
fContents = fContents.replace(/[ \t]*\/\* \$\{DEFAULTS\} \*\/[ \t]*\n/, macros.defaults)
fContents = fContents.replace(/[ \t]*\/\* \$\{EVENT_METHODS\} \*\/[ \t]*\n/, macros.onlyEventMethods)
fContents = fContents.replace(/[ \t]*\/\* \$\{METHODS\} \*\/[ \t\r]*\n/, macros.methods)
fContents = fContents.replace(/[ \t]*\/\* \$\{METHOD_LIST\} \*\/[ \t\r]*\n/, macros.methodList)
fContents = fContents.replace(/[ \t]*\/\* \$\{ENUMS\} \*\/[ \t\r]*\n/, macros.enums)
fContents = fContents.replace(/[ \t]*\/\* \$\{EVENTS\} \*\/[ \t\r]*\n/, macros.events)
fContents = fContents.replace(/[ \t]*\/\* \$\{IMPORTS\} \*\/[ \t\r]*\n/, macros.imports)
fContents = fContents.replace(/[ \t]*\/\* \$\{INITIALIZATION\} \*\/[ \t\r]*\n/, macros.initialization)
fContents = fContents.replace(/[ \t]*\/\* \$\{DEFAULTS\} \*\/[ \t\r]*\n/, macros.defaults)
fContents = fContents.replace(/[ \t]*\/\* \$\{EVENT_METHODS\} \*\/[ \t\r]*\n/, macros.onlyEventMethods)
fContents = fContents.replace(/\$\{readable\}/g, version.readable)
fContents = fContents.replace(/\$\{major\}/g, version.major)
fContents = fContents.replace(/\$\{minor\}/g, version.minor)
Expand Down