Skip to content

Commit

Permalink
Changes bulk remap to selection and includes (#1330)
Browse files Browse the repository at this point in the history
This PR changes bulk remap to no longer scan the currently selected
updateMode but instead always takes selection (because that's what
should happen in Inspect)

Also changes implementation so the `match` doesn't just have to
startWith the word, but can be anywhere.
  • Loading branch information
six7 authored Oct 10, 2022
1 parent 3767f07 commit e9c924a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugin/asyncMessageHandlers/bulkRemapTokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AsyncMessageChannelHandlers } from '@/AsyncMessageChannel';
import { UpdateMode } from '@/constants/UpdateMode';
import { AsyncMessageTypes } from '@/types/AsyncMessages';
import { defaultNodeManager, NodeManagerNode } from '../NodeManager';
import { updatePluginData } from '../pluginData';
Expand All @@ -7,13 +8,13 @@ import { sendSelectionChange } from '../sendSelectionChange';
export const bulkRemapTokens: AsyncMessageChannelHandlers[AsyncMessageTypes.BULK_REMAP_TOKENS] = async (msg) => {
try {
const { oldName, newName } = msg;
const allWithData = await defaultNodeManager.findNodesWithData({});
const allWithData = await defaultNodeManager.findNodesWithData({ updateMode: UpdateMode.SELECTION });
const updatedNodes: NodeManagerNode[] = [];

allWithData.forEach((node) => {
const { tokens } = node;
const updatedTokens = Object.entries(tokens).reduce<Record<string, string>>((acc, [key, val]) => {
if (val.startsWith(oldName)) {
if (val.includes(oldName)) {
acc[key] = val.replace(oldName, newName);
} else {
acc[key] = val;
Expand Down

2 comments on commit e9c924a

@vercel
Copy link

@vercel vercel bot commented on e9c924a Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ft-storybook – ./

ft-storybook-six7.vercel.app
ft-storybook.vercel.app
ft-storybook-git-main-six7.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e9c924a Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

figma-tokens – ./

figma-tokens-git-main-six7.vercel.app
figma-tokens-six7.vercel.app
figma-tokens.vercel.app

Please sign in to comment.